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?

- 457
- 2
- 9
- 24
-
that a typo for launchmode? – t0mm13b May 02 '16 at 15:57
-
no, I need launchMode singleInstance for some features, but now I have no idea, how can I use camera intent with this – Oleg Ryabtsev May 02 '16 at 15:59
-
`android:launchMode="singleInstance"`<-- compare with what you said. – t0mm13b May 02 '16 at 16:01
-
Oh, that was mistake, thanks :) – Oleg Ryabtsev May 02 '16 at 16:08
-
Have you read [this](http://developer.android.com/training/camera/photobasics.html)? – t0mm13b May 02 '16 at 16:12
1 Answers
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);
}
}
}

- 76
- 3