-5

Let me clarify this first, this isn't anything similar to asking whether or not I can make my own camera application to capture and process an image however I want. What I want is to devise an application which gets launched in background whenever an image is capture by my android phone's camera (using any application, factory or otherwise), so that I can process that image and save it anyway I want.

Is it possible without diving into the root level programming?

1 Answers1

-1

Probably it can be implemented with the careful use Broadcast Receivers for the event of image capture by camera. Though i haven't implemented this before but it seems reasonable to work. It involves three following steps --

1. Creation of Broadcast Receiver

public class MyReceiver extends BroadcastReceiver {
    public MyReceiver() {
    }

    @Override
    public void onReceive(Context context, Intent intent) {

        Toast.makeText(context, "image captured by camera", Toast.LENGTH_SHORT).show();
    }
}

2. Registering Receiver in manifest file

Under <application> tag in manifest file put this intent receiver. action here defines on what actions you want your receiver to be activated/ listen. For camera button event action is android.intent.action.CAMERA_BUTTON.

<receiver android:name=".MyReceiver" >
             <intent-filter>
                 <action android:name="android.intent.action.CAMERA_BUTTON" />
             </intent-filter>
</receiver>

3. Registering the receiver in your activity

IntentFilter filter = new IntentFilter();
intentFilter.addAction(getPackageName() + "android.intent.action.CAMERA_BUTTON");

MyReceiver myReceiver = new MyReceiver();
registerReceiver(myReceiver, filter);

To unregister a receiver in onStop() or onPause() of the activity the following can be used --

@Override
protected void onPause() {
    unregisterReceiver(myReceiver);
    super.onPause();
}

I am hoping this should work fine. If not, let me know what problem you are facing.

jack jay
  • 2,493
  • 1
  • 14
  • 27