我正在尝试在onBackPressed评估我的应用
public void onBackPressed() {
new AlertDialog.Builder(ChooseMenu.this)
.setMessage("Rate My Application")
.setCancelable(true)
.setPositiveButton("Rate it",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
mcontext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + APP_PNAME)));
}
}).setNegativeButton("Later", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
finish();
}
}).show();
LogCat:
11-23 23:22:09.476: E/AndroidRuntime(594): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=market://details?id=com.moblication5.india.homeeelectriccalculator }
11-23 23:22:09.476: E/AndroidRuntime(594): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1409)
11-23 23:22:09.476: E/AndroidRuntime(594): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
11-23 23:22:09.476: E/AndroidRuntime(594): at android.app.Activity.startActivityForResult(Activity.java:2827)
11-23 23:22:09.476: E/AndroidRuntime(594): at android.app.Activity.startActivity(Activity.java:2933)
11-23 23:22:09.476: E/AndroidRuntime(594): at com.moblication5.india.homeeelectriccalculator.ChooseMenu$6.onClick(ChooseMenu.java:167)
11-23 23:22:09.476: E/AndroidRuntime(594): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:159)
11-23 23:22:09.476: E/AndroidRuntime(594): at android.os.Handler.dispatchMessage(Handler.java:99)
11-23 23:22:09.476: E/AndroidRuntime(594): at android.os.Looper.loop(Looper.java:123)
11-23 23:22:09.476: E/AndroidRuntime(594): at android.app.ActivityThread.main(ActivityThread.java:3683)
11-23 23:22:09.476: E/AndroidRuntime(594): at java.lang.reflect.Method.invokeNative(Native Method)
11-23 23:22:09.476: E/AndroidRuntime(594): at java.lang.reflect.Method.invoke(Method.java:507)
11-23 23:22:09.476: E/AndroidRuntime(594): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-23 23:22:09.476: E/AndroidRuntime(594): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-23 23:22:09.476: E/AndroidRuntime(594): at dalvik.system.NativeStart.main(Native Method)
答案 0 :(得分:3)
更改
mcontext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + APP_PNAME)));
到
mcontext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + APP_PNAME)));
并非所有手机都安装了Google Play,并知道如何处理market://
网址。
其他一些解决方案: "no activity found to handle intent" Not all phones have Android Market installed
答案 1 :(得分:1)
我猜你错过了初始化上下文
在onCreate
mcontext = this;
答案 2 :(得分:1)
公开定义mcontext
,并在onCreate
中对其进行初始化。例如:
public Context mcontext;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mcontext = this;
}
然后改变这个:
mcontext.startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id=" + APP_PNAME)));
对此:
mcontext.startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("https://play.google.com/store/apps/details?id=" + APP_NAME)));
其中APP_NAME
是您应用的包名称。