質問

I am trying to launch Play Store so that when the user clicks Rate Us in the drop down menu that it will load my app in the google market place. So far when user click Rate Us in the menu , the app does nothing and there is no information in the 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;
}

All I need is that when the user clicks Rate on the inflated menu that it will load my app in the market place for them to add a rating. the Logcat says that there is no activity to handle intent.

役に立ちましたか?

解決

Your code in unclear. Also you are not even starting the Activity.

This two lines should work perfectly.

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

他のヒント

Please use the following code when click on Rate button

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)));
    }
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top