mcfly soft
mcfly soft

Reputation: 11645

Confusing behaviour with intents in Android

I call GooglePlay from my app through an intent and again after I kill my own app:

Intent intent = new Intent(Intent.ACTION_VIEW);
String sModule = "market://search?q=pub:mycompany";
intent.setData(Uri.parse(sModule));
startActivity(intent);

finish();
android.os.Process.killProcess(android.os.Process.myPid());

Task manager shows, that only GooglePlay is running. My app isn't there anymore.

So my focus is GooglePlay at the moment. When going to the Desktop through the Home-Button and calling my App again it directs me to GooglePlay again.

Why is that? How can I call GooglePlay from my app independently?

I expected that when starting my app again, which I had previously killed, it would start my app and not focus on google play.

Upvotes: 1

Views: 102

Answers (1)

ytRino
ytRino

Reputation: 1459

keyword is "launchMode" and "task".
this type of problems are so annoying and much complicated in android.
but this time you can try this.

Intent intent = new Intent(Intent.ACTION_VIEW);
String sModule = "market://search?q=pub:mycompany";
intent.setData(Uri.parse(sModule));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);

finish();

if u cant solve, try combine another flags with FLAG_ACTIVITY_NEW_TASK. cheers!

Upvotes: 1

Related Questions