How to open the Google Play Store directly from my Android application?

后端 未结 23 2726
既然无缘
既然无缘 2020-11-22 02:00

I have open the Google Play store using the following code

Intent i = new Intent(android.content.Intent.ACTION_VIEW);
i.setData(Uri.parse(\"https://play.goo         


        
23条回答
  •  被撕碎了的回忆
    2020-11-22 02:26

    All of the above answers open Google Play in a new view of the same app, if you actually want to open Google Play (or any other app) independently:

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

    The important part is that actually opens google play or any other app independently.

    Most of what I have seen uses the approach of the other answers and it was not what I needed hopefully this helps somebody.

    Regards.

提交回复
热议问题