I'm trying to create a switch camera button with my custom gui. In my CustomCam extends SherlockFragmentActivity
I have a method called onSwitch() that gets called from the xml android:onClick="onSwitch"
Here is the method:
public void onClickSwitchButton(View view) {
if (current == std) {
ffc = CustomCamFragment.newInstance(true);
current = ffc;
getSupportFragmentManager().beginTransaction()
.replace(R.id.container, current).commit();
isFrontCamera=true;
return;
}
if (current == ffc) {
std = CustomCamFragment.newInstance(false);
current = std;
isFrontCamera=false;
}
getSupportFragmentManager().beginTransaction()
.replace(R.id.container, current).commit();
}
I know that the method triggers because of breakpoints and log statements, but my screen simply goes black, and then comes back as the same std view.
Note: I realize I have to detect if the phone has more than 1 camera, or no cameras at all. But for now, this app is not something I'll be publishing. Just want it for my own personal use.
My CustomCamFragment:
public class CustomCamFragment extends CameraFragment {
private static final String KEY_USE_FFC = "com.commonsware.cwac.camera.demo.USE_FFC";
public static CustomCamFragment newInstance(boolean useFFC) {
CustomCamFragment f = new CustomCamFragment();
Bundle args = new Bundle();
args.putBoolean(KEY_USE_FFC, useFFC);
f.setArguments(args);
return (f);
}