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.