I have a ScanActivity from which I instantiate a class(Preview) which clicks images and sets a callback on the Camera object. If the operation on callback is successful, I want to return back to ScanActivity. Ex:
class Preview extends SurfaceView implements SurfaceHolder.Callback{
Camera mCamera;
Preview(){} //constructor to initialize mCamera
public void start(){
mCamera.startPreview();
mCamera.setPreviewCallback(new Camera.PreviewCallback() {
public void onPreviewFrame(byte[] data, Camera camera) {
/*
if(scanSuccessful){
return to activity
}
*/
}
}
}
class ScanActivity extends Activity{
public void onCreate(){
Preview p = new Preview();
preview.start();
}
}
From the callback I want to return back to the calling activity(ScanActivity) in case of a successful scan. I know broadcast receiver is one way of achieving it, is there any other way? And what are the pros and cons of using them?