I've created a browser application with main activity which response to the following intents:
<intent-filter>
<data android:scheme="http"/>
<data android:scheme="https"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<action android:name="android.intent.action.VIEW"/>
</intent-filter>
On url click from other task (gmail, sms) if i choose my application, the activity is open in the same task as the calling task. When I choose different browser (Mozila firefox, chrome, dolphine) they are opening in different task.
Looking on other browsers manifest, I see that no one using android:launchMode="singleTask".
I don't want to use single task flag since it is not recommended by google and also makes me other prolems.
I tried to understand how does other browsers do it but didn't figure it out.
any ideas? is there other way to open my activity in different task without using singleTask flag?
You can check in onCreate if the activity is running in a single task. If not just finish() it and create it again with using FLAG_ACTIVITY_NEW_TASK
This may help you
ActivityManager activityManager = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE);
List<RunningTaskInfo> tasks = activityManager.getRunningTasks(Integer.MAX_VALUE);
for (RunningTaskInfo task : tasks) {
if (ctx.getPackageName().equalsIgnoreCase(task.baseActivity.getPackageName()))
// check if it's the only one activity or whatever
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With