2014-05-09 39 views
0

我試圖啓動Play Store,以便當用戶在下拉菜單中點擊Rate Us時,它將在谷歌市場中加載我的應用程序。到目前爲止,當用戶在菜單中單擊Rate Us時,該應用程序不執行任何操作,並且logcat中沒有任何信息。啓動Google Play商店意圖不工作

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表示沒有活動來處理意圖。

回答

0

您的代碼不清楚。你甚至沒有開始Activity

這兩條線應該完美地工作。

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

確切位置在哪裏我把那得到它的工作?在Rate.class下我應該只有這個代碼? – user2727048

+0

把它放在'點擊率'按鈕上 – Libin

+0

我沒有一個按鈕準確的速度。我有一個菜單inflater和率是其中一個選項。我將該代碼放在開關中,當R.id.Rate被點擊時,但它不起作用 – user2727048

0

請使用下面的代碼時,點擊率按鈕

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