¿Cómo abrir Google Play Store directamente desde mi aplicación de Android?

He abierto la tienda de Google Play con el código siguiente

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 / tienda de juego). Necesito abrir la aplicación directamente en playstore.

Puede hacerlo utilizando el prefijo market:// .

 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))); } 

Utilizamos un bloque try/catch aquí porque se producirá una Exception si Play Store no está instalado en el dispositivo de destino.

NOTA : cualquier aplicación puede registrarse como capaz de manejar el market://details?id=<appId> Uri, si desea apuntar específicamente a Google Play, compruebe la respuesta Berťák

Muchas respuestas aquí sugieren usar Uri.parse("market://details?id=" + appPackageName)) para abrir Google Play, pero creo que es insuficiente en realidad:

Algunas aplicaciones de terceros pueden usar sus propios filtros de intenciones con el esquema "market://" definido , por lo que pueden procesar Uri suministrado en lugar de Google Play (experimenté esta situación con la aplicación egSnapPea). La pregunta es "¿Cómo abrir Google Play Store?", Por lo que supongo, que no desea abrir ninguna otra aplicación. También tenga en cuenta que, por ejemplo, la evaluación de aplicaciones sólo es relevante en la aplicación GP Store, etc.

Para abrir Google Play Y SOLO Google Play, utilizo este método:

 public static void openAppRating(Context context) { // you can also use BuildConfig.APPLICATION_ID String appId = context.getPackageName(); Intent rateIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appId)); boolean marketFound = false; // find all applications able to handle our rateIntent final List<ResolveInfo> otherApps = context.getPackageManager() .queryIntentActivities(rateIntent, 0); for (ResolveInfo otherApp: otherApps) { // look for Google Play application if (otherApp.activityInfo.applicationInfo.packageName .equals("com.android.vending")) { ActivityInfo otherAppActivity = otherApp.activityInfo; ComponentName componentName = new ComponentName( otherAppActivity.applicationInfo.packageName, otherAppActivity.name ); // make sure it does NOT open in the stack of your activity rateIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // task reparenting if needed rateIntent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); // if the Google Play was already open in a search result // this make sure it still go to the app page you requested rateIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // this make sure only the Google Play app is allowed to // intercept the intent rateIntent.setComponent(componentName); context.startActivity(rateIntent); marketFound = true; break; } } // if GP not present on device, open web browser if (!marketFound) { Intent webIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id="+appId)); context.startActivity(webIntent); } } 

El punto es que cuando más aplicaciones junto a Google Play puedan abrir nuestra intención, se omite el diálogo de selección de aplicaciones y se inicia la aplicación de GP directamente.

ACTUALIZACIÓN: A veces parece que sólo abre la aplicación de GP, sin abrir el perfil de la aplicación. Como TrevorWiley sugirió en su comentario, Intent.FLAG_ACTIVITY_CLEAR_TOP podría solucionar el problema. (No lo probé yo mismo …)

Vea esta respuesta para entender lo que hace Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED .

Ir a Android Developer enlace oficial como tutorial paso a paso ver y obtuvo el código para su paquete de aplicaciones de la tienda de juegos si existe o jugar aplicaciones de la tienda no existe a continuación, abra la aplicación del navegador web.

Enlace oficial de Android Developer

http://developer.android.com/distribute/tools/promote/linking.html

Vinculación a una página de aplicación

Desde un sitio web: http://play.google.com/store/apps/details?id=<package_name>

Desde una aplicación para Android: market://details?id=<package_name>

Vinculación a una lista de productos

Desde un sitio web: http://play.google.com/store/search?q=pub:<publisher_name>

Desde una aplicación para Android: market://search?q=pub:<publisher_name>

Vinculación a un resultado de búsqueda

Desde un sitio web: http://play.google.com/store/search?q=<search_query>&c=apps

Desde una aplicación de Android: market://search?q=<seach_query>&c=apps

prueba esto

 Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://details?id=com.example.android")); startActivity(intent); 

TODAS LAS RESPUESTAS ANTERIORES ABREN GOOGLE PLAY EN UNA NUEVA VISTA DE LA MISMA APP, SI USTED REALMENTE QUIERE ABRIR GOOGLE PLAY (o cualquier otra aplicación) INDEPENDIENTEMENTE:

  Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.android.vending"); ComponentName comp = new ComponentName("com.android.vending", "com.google.android.finsky.activities.LaunchUrlHandlerActivity"); // package name and activity launchIntent.setComponent(comp); launchIntent.setData(Uri.parse("market://details?id=com.facebook.katana")); startActivity(launchIntent); 

La parte importante es que realmente se abre google play o cualquier otra aplicación de forma independiente.

(La mayoría de lo que he visto utiliza el enfoque de las otras respuestas y no era lo que necesitaba espero que esto ayude a alguien)

Saludos.

Puedes comprobar si la aplicación Google Play Store está instalada y, de ser así, puedes usar el protocolo "market: //" .

 final String my_package_name = "........." // <- HERE YOUR PACKAGE NAME!! String url = ""; try { //Check whether Google Play store is installed or not: this.getPackageManager().getPackageInfo("com.android.vending", 0); url = "market://details?id=" + my_package_name; } catch ( final Exception e ) { url = "https://play.google.com/store/apps/details?id=" + my_package_name; } //Open the app page in Google Play store: final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); startActivity(intent); 

Mercado del uso: //

 Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + my_packagename)); 

Tu puedes hacer:

 final Uri marketUri = Uri.parse("market://details?id=" + packageName); startActivity(new Intent(Intent.ACTION_VIEW, marketUri)); 

Obtener referencia aquí :

También puede probar el enfoque descrito en la respuesta aceptada de esta pregunta: No se puede determinar si Google Play Store está instalado o no en el dispositivo Android

Solución lista para usar:

 public class GoogleServicesUtils { public static void openAppInGooglePlay(Context context) { final String appPackageName = context.getPackageName(); try { context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName))); } catch (android.content.ActivityNotFoundException e) { // if there is no Google Play on device context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName))); } } } 

Basado en la respuesta de Eric.

Si quieres abrir Google Play Store desde tu aplicación, utiliza este comando: direct @: market://details?gotohome=com.yourAppName , abrirá las páginas de Google Play Store de tu aplicación.

Mostrar todas las aplicaciones de un editor específico

Buscar aplicaciones que utilicen la consulta en su título o descripción

Referencia: https://tricklio.com/market-details-gotohome-1/

Mientras que la respuesta de Eric es correcta y el código de Berťák también funciona. Creo que esto combina ambos con más elegancia.

 try { Intent appStoreIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)); appStoreIntent.setPackage("com.android.vending"); startActivity(appStoreIntent); } catch (android.content.ActivityNotFoundException exception) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName))); } 

Mediante el uso de setPackage , se obliga al dispositivo a utilizar Play Store. Si no hay Play Store instalado, se Exception la Exception .

He combinado tanto Berťák y Stefano Munarini respuesta a la creación de una solución híbrida que maneja ambos Valore esta aplicación y Mostrar más escenario de la aplicación .

  /** * This method checks if GooglePlay is installed or not on the device and accordingly handle * Intents to view for rate App or Publisher's Profile * * @param showPublisherProfile pass true if you want to open Publisher Page else pass false to open APp page * @param publisherID pass Dev ID if you have passed PublisherProfile true */ public void openPlayStore(boolean showPublisherProfile, String publisherID) { //Error Handling if (publisherID == null || !publisherID.isEmpty()) { publisherID = ""; //Log and continue Log.w("openPlayStore Method", "publisherID is invalid"); } Intent openPlayStoreIntent; boolean isGooglePlayInstalled = false; if (showPublisherProfile) { //Open Publishers Profile on PlayStore openPlayStoreIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pub:" + publisherID)); } else { //Open this App on PlayStore openPlayStoreIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getPackageName())); } // find all applications who can handle openPlayStoreIntent final List<ResolveInfo> otherApps = getPackageManager() .queryIntentActivities(openPlayStoreIntent, 0); for (ResolveInfo otherApp : otherApps) { // look for Google Play application if (otherApp.activityInfo.applicationInfo.packageName.equals("com.android.vending")) { ActivityInfo otherAppActivity = otherApp.activityInfo; ComponentName componentName = new ComponentName( otherAppActivity.applicationInfo.packageName, otherAppActivity.name ); // make sure it does NOT open in the stack of your activity openPlayStoreIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // task reparenting if needed openPlayStoreIntent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); // if the Google Play was already open in a search result // this make sure it still go to the app page you requested openPlayStoreIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // this make sure only the Google Play app is allowed to // intercept the intent openPlayStoreIntent.setComponent(componentName); startActivity(openPlayStoreIntent); isGooglePlayInstalled = true; break; } } // if Google Play is not Installed on the device, open web browser if (!isGooglePlayInstalled) { Intent webIntent; if (showPublisherProfile) { //Open Publishers Profile on web browser webIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/search?q=pub:" + getPackageName())); } else { //Open this App on web browser webIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + getPackageName())); } startActivity(webIntent); } } 

Uso

  • Para abrir el perfil de editores
  @OnClick(R.id.ll_more_apps) public void showMoreApps() { openPlayStore(true, "Hitesh Sahu"); } 
  • Para abrir la página de la aplicación en PlayStore
 @OnClick(R.id.ll_rate_this_app) public void openAppInPlayStore() { openPlayStore(false, ""); } 
  • ¿Es posible conocer la fuente (por ejemplo, Google Play) de la aplicación para Android?
  • La aplicación no aparece en Android Market para la tableta Motorola XOOM
  • ¿La publicación Alpha / Beta apk funciona con aplicaciones no publicadas en Google Play?
  • ¿Cómo puedo saber por qué el mercado de Android está filtrando mi aplicación en determinados teléfonos
  • Error al agregar la biblioteca de facturación en la aplicación
  • ¿Cómo se especifica en AndroidManifest.xml que desea prohibir la instalación en dispositivos más pequeños que un dispositivo de 4,7 pulgadas?
  • Obtener el atributo '' android: icon 'atributo: no es un valor de cadena "al cargar un APK en la tienda de reproducción
  • Suscripción de Google PlayIm no presente
  • Cómo probar In App Subscription en android
  • ¿Puedo usar la tarjeta de crédito de otra persona para registrar mi cuenta de desarrollador de Android?
  • Android Diseño principios de diseño
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.