package com.NYSapps.flashy_blog;
import android.app.Activity;
import android.hardware.Camera;
import android.hardware.Camera.Parameters;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ToggleButton;
public class MainActivity extends Activity implements OnClickListener {
ToggleButton tb;
public static Camera ourCam = null;
Parameters p;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tb = (ToggleButton) findViewById(R.id.toggleButton1);
tb.setOnClickListener(this);
if (ourCam != null) {
tb.setChecked(true);
}
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (tb.isChecked()) {
ourCam = Camera.open();
p = ourCam.getParameters();
p.setFlashMode(Parameters.FLASH_MODE_TORCH);
ourCam.setParameters(p);
ourCam.startPreview();
} else {
ourCam.stopPreview();
ourCam.release();
}
}
}
For those who dabble in Android developments. I'll be discussing struggles that I have come across as well as new apps that I'm creating, tutorials how to fix those problems, new features to old apps, and maybe even some app reviews!
Monday, June 16, 2014
Flashy Complete code
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment