문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top