如何从按钮重定向到我的Play商店页面?

时间:2017-07-02 12:24:54

标签: android android-intent

我希望我的用户能够按“其他游戏”按钮,并通过Google Play应用将其重定向到我的开发者游戏商店页面。 我做了如下,但它重定向不正确。

final String appPackageName2 = "MyCompany%20Name"; // getPackageName() from Context or Activity object
     try {
           activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://developer?id=" + appPackageName2)));
     } catch (android.content.ActivityNotFoundException anfe) {
           activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/developer?id=" + appPackageName2)));
     }

1 个答案:

答案 0 :(得分:1)

要打开开发者页面是不同的,请看一个例​​子:

final String developer_id = "my_dev_id";

try {

  activity.startActivity(
    new Intent(
      Intent.ACTION_VIEW, 
      Uri.parse("market://dev?id=" + developer_id)
    )
  );

} catch (android.content.ActivityNotFoundException anfe) {

  activity.startActivity(
    new Intent(
      Intent.ACTION_VIEW, 
      Uri.parse("https://play.google.com/store/dev?id=" + developer_id)
    )
  );

}

要获取信息,请访问developer page,在那里您可以找到有关您的ID和其他内容的所有信息。运气。

文档:Link to Google Play