3

This is a basic code to redirect your users from inside your Android app to Google Play Store and it is working as expected on most device:

final String appPackageName = activity.getPackageName();
try {
    Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName));
    i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
    activity.startActivity(i);
} catch (android.content.ActivityNotFoundException anfe) {
    activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
}

However on some custom Android based OS (like Mi UI) it redirect users into their own custom store (ie. Mi Store) instead of Google Play Store. As my application (and I think a lot of others) did not listed in those custom store, the users may mistakenly assume that the app is not registered as official app or something.

Is there any way to make it detect if it is correctly redirected to Google Play Store or not?

Note: The phones I used to test have Google Play Store installed, but still not redirected to it.

Muhammad Waleed
  • 2,517
  • 4
  • 27
  • 75
koceeng
  • 2,169
  • 3
  • 16
  • 37
  • 1
    This happens when custom UI makers have same URL scheme as of Android to promote their application stores. Here is the detailed solution to the problem http://stackoverflow.com/a/28090925/1061944 – Murtaza Khursheed Hussain Jan 11 '17 at 12:03
  • As some of you might think it is duplicate of [this post](http://stackoverflow.com/questions/11753000/how-to-open-the-google-play-store-directly-from-my-android-application/28090925#28090925), I think it really is not. As the linked post only ask to open Google Play from inside Android app (generally) not specifically mention **ONLY** Google Play and not any other market store. As a lot of developer might not tested their app on custom Android based-OS yet, I think if this question get a good answer, it will help a lot of them – koceeng Jan 11 '17 at 12:04
  • Then do post you answer when you found it. it will help other searchers. – Murtaza Khursheed Hussain Jan 11 '17 at 12:06
  • I'm also still searching for answer. And I will try your linked answer first thing in the morning. Thanks a lot @MurtazaKhursheedHussain – koceeng Jan 11 '17 at 12:07

0 Answers0