qomg

qomg

enjoy life

Open App Store on Android

Open specified application

private void openPlayStore(String packageName) {
  Intent playStoreIntent = new Intent(
    Intent.ACTION_VIEW,
    Uri.parse("market://details?id=" + packageName)
  // Open instant app
  // Uri.parse("market://launch?id=" + packageName)
  );
  setFlags(playStoreIntent);
  try {
    startActivity(playStoreIntent);
  } catch (Exception e) {
    Intent webIntent = new Intent(
      Intent.ACTION_VIEW,
      Uri.parse("https://play.google.com/store/apps/details?id=" + packageName)
      // Open instant app
      // Uri.parse("https://play.google.com/store/apps/details?id=" + packageName + "&launch=true")
    );
    setFlags(webIntent);
    startActivity(webIntent);
  }
}

@SuppressWarnings("deprecation")
private void setFlags(Intent intent) {
  intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
  } else {
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
  }
}

Search for apps (specified publisher)

String urlApp = "market://search?q=pub:Google+Inc.";
String urlWeb = "http://play.google.com/store/search?q=pub:Google+Inc.";
try {
    Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(urlApp));
    setFlags(i);
    startActivity(i);
} catch (android.content.ActivityNotFoundException anfe) {
    Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(urlWeb));
    setFlags(i);
    startActivity(i);
}
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.