J'ai ouvert le Google Play store en utilisant le code suivant
Intent i = new Intent(android.content.Intent.ACTION_VIEW);
i.setData(Uri.parse("https://play.google.com/store/apps/details?id=my packagename "));
startActivity(i);.
Mais il me montre un Complete Action View comme pour sélectionner l'option (navigateur/play store). J'ai besoin d'ouvrir l'application dans le Play Store directement.
Vous pouvez le faire en utilisant le préfixe [market://
] (https://developer.android.com/distribute/tools/promote/linking.html).
final String appPackageName = getPackageName(); // getPackageName() from Context or Activity object
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
} catch (android.content.ActivityNotFoundException anfe) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
}
Nous utilisons un bloc try/catch
ici car une Exception
sera levée si le Play Store n'est pas installé sur l'appareil cible.
NOTE : n'importe quelle application peut s'enregistrer comme capable de gérer le market://details?id=<appId>
Uri, si vous voulez cibler spécifiquement Google Play, vérifiez la réponse Berťák.
utiliser market://
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + my_packagename));
Vous pouvez le faire :
final Uri marketUri = Uri.parse("market://details?id=" + packageName);
startActivity(new Intent(Intent.ACTION_VIEW, marketUri));
obtenir la référence [ici][1] :
Vous pouvez également essayer l'approche décrite dans la réponse acceptée de cette question : https://stackoverflow.com/questions/10551531/cannot-determine-whether-google-play-store-is-installed-or-not-on-android-device
[1] : http://developer.android.com/distribute/googleplay/promote/linking.html