He abierto la tienda de Google Play usando el siguiente código
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);.
Pero me muestra una vista de acción completa como para seleccionar la opción (navegador/play store). Necesito abrir la aplicación en Play Store directamente.
Puede hacerlo utilizando el prefijo [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)));
}
Aquí utilizamos un bloque try/catch
porque se lanzará una Exception
si la Play Store no está instalada en el dispositivo de destino.
NOTA: cualquier aplicación puede registrarse como capaz de manejar el market://details?id=<appId>
Uri, si quieres apuntar específicamente a Google Play comprueba la respuesta Berťák.
utilizar market://
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + my_packagename));
Puedes hacerlo:
final Uri marketUri = Uri.parse("market://details?id=" + packageName);
startActivity(new Intent(Intent.ACTION_VIEW, marketUri));
obtener Referencia aquí:
También puedes probar el enfoque descrito en la respuesta aceptada de esta pregunta: https://stackoverflow.com/questions/10551531/cannot-determine-whether-google-play-store-is-installed-or-not-on-android-device