I have an activity called MainActivity and a Service called CameraService which binds to a socket port. Whenever the socket receives the string "camera" the Service broadcast to MainActivity to launch camera.
Intent launchIntent = new Intent(MainActivity._LAUNCH_CAMERA_ACTION);
sendBroadcast(launchIntent);
MainActivity
registers _LAUNCH_CAMERA_ACTION
and a BroadcastReceiver.
IntentFilter filter = new IntentFilter();
filter.addAction(_LAUNCH_CAMERA_ACTION);
registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (_LAUNCH_CAMERA_ACTION.equalsIgnoreCase(intent.getAction())) {
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
MainActivity.this.startActivityForResult(cameraIntent, REQUEST_CAMERA);
}
}
}, filter);
Whenever the camera intent is called the program presents an unhandled exception and it terminates because of the exception.
Any ideas why this happens?