【问题标题】:Launching Google Play Store Intent not working启动 Google Play 商店 Intent 不起作用
【发布时间】:2014-05-09 02:30:14
【问题描述】:

我正在尝试启动Play Store,以便当用户在下拉菜单中单击Rate Us 时,它将在谷歌市场中加载我的应用程序。到目前为止,当用户点击菜单中的Rate Us 时,应用程序什么也不做,logcat 中也没有任何信息。

public boolean onOptionsItemSelected(MenuItem item){
switch(item.getItemId()){
case R.id.About:
    Intent i = new Intent(this, About.class);
    startActivity(i);
    break;
case R.id.exit:
    finish();
    break;
case R.id.Rate:
    Intent marketIntent = new Intent(Intent.ACTION_VIEW,
               Uri.parse("market://details?
 id="+"com.androidsleepmachine.gamble"));
        startActivity(marketIntent);
}
return false;
}

我需要的是,当用户在膨胀的菜单上单击“评分”时,它会将我的应用加载到市场中,以便他们添加评分。 Logcat 说没有活动来处理意图。

【问题讨论】:

    标签: android eclipse android-intent


    【解决方案1】:

    您的代码不清楚。此外,您甚至没有启动Activity。

    这两行应该可以完美运行。

    Intent marketIntent = new Intent(Intent.ACTION_VIEW,
           Uri.parse("market://details?id="+"com.androidsleepmachine.gamble"));
    startActivity(marketIntent);
    

    【讨论】:

    • 我应该把它放在哪里才能让它工作?在 Rate.class 下我应该只有那个代码?
    • 点击Rate button把它放进去
    • 我没有专门用于速率的按钮。我有一个菜单充气机,价格是选项之一。当点击 R.id.Rate 但它不起作用时,我将该代码放在开关下
    • 它应该可以工作。如果调用了选择的选项项,请尝试调试。发布更新的代码。明天早上去看看
    【解决方案2】:

    点击评分按钮时请使用以下代码

    final String appPackageName = context.getPackageName(); 
    try {
        context.startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("market://details?id=" + appPackageName)));
        } catch (android.content.ActivityNotFoundException anfe) {
                context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName)));
        }
    

    【讨论】:

      猜你喜欢
      • 2021-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-12
      相关资源
      最近更新 更多