Question

When I open a link inside the Facebook app, it opens a new task for the browser while I can switch back to the Facebook app instead of opening the browser inside itself like an ordinary Activity. But when I launch an Intent to my application's Google Play page it behaves like an Activity inside my app instead of launching a separate instance for Google Play.

Here's how I'm starting the Intent:

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=MY.APP.PACKAGE")));

I found this thread and wrote this snippet:

Intent i = new Intent(Intent.ACTION_VIEW);

i.setData(Uri.parse("market://details?id=MY.APP.PACKAGE"));
i.addCategory(Intent.CATEGORY_LAUNCHER);
i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

startActivity(i);

Which fails with this message in logcat:

04-29 12:35:42.681: E/AndroidRuntime(8482): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW cat=[android.intent.category.LAUNCHER] dat=market://details?id=MY.APP.PACKAGE flg=0x50000000 }

Any ideas?

Was it helpful?

Solution

You just need to remove the addCategory() call and it should work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top