0

I have an Activity with android:launchMode="singleInstance" . I want launch camera from this and then process result, but startActivityForResult doesn't work with singleInstance. So maybe it's possible to get result from camera using onNewIntent method? If it's possible, how can I implement this?

Oleg Ryabtsev
  • 457
  • 2
  • 9
  • 24

1 Answers1

0

You might want to look at both singleTask and singleInstance.

singleTask:

The system creates a new task and instantiates the activity at the root of the new task. However, if an instance of the activity already exists in a separate task, the system routes the intent to the existing instance through a call to its onNewIntent() method, rather than creating a new instance. Only one instance of the activity can exist at a time.

Note: Although the activity starts in a new task, the Back button still returns the user to the previous activity.

singleInstance:

Same as "singleTask", except that the system doesn't launch any other activities into the task holding the instance. The activity is always the single and only member of its task; any activities started by this one open in a separate task.

Note: That means, the activity with launch mode is always in a single activity instance task. This is a very specialized mode and should only be used in the applications that are implemented entirely as one activity.

You could try something like this

protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    Uri uri = intent.getData();
    if (uri != null && uri.toString().startsWith(CALLBACK_URL)) {

        try {
            //load image goes 

         } catch (Exception e) {
             Log.e(TAG, e.getMessage(), e);
         }
    }
}
Audakel
  • 76
  • 3