调用市场URL时,android Intent.ACTION_VIEW崩溃

时间:2012-02-13 11:16:50

标签: android android-intent

我想为我的应用程序创建一个反馈字段。我只想将用户重定向到这样的市场

String APP_MARKET_URL = "market://details?id=com.my.application"; 

Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse(APP_MARKET_URL)); 
this.startActivity(intent);

但是当我执行它时,我有这个错误:

02-13 11:07:33.147: W/dalvikvm(238): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
02-13 11:07:33.155: E/AndroidRuntime(238): Uncaught handler: thread main exiting due to uncaught exception
02-13 11:07:33.225: E/AndroidRuntime(238): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.picca.pointage.NoterApplication }
02-13 11:07:33.225: E/AndroidRuntime(238):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408)
02-13 11:07:33.225: E/AndroidRuntime(238):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
02-13 11:07:33.225: E/AndroidRuntime(238):  at android.app.Activity.startActivityForResult(Activity.java:2749)
02-13 11:07:33.225: E/AndroidRuntime(238):  at android.app.Activity.startActivity(Activity.java:2855)
02-13 11:07:33.225: E/AndroidRuntime(238):  at android.preference.Preference.performClick(Preference.java:829)
02-13 11:07:33.225: E/AndroidRuntime(238):  at android.preference.PreferenceScreen.onItemClick(PreferenceScreen.java:190)
02-13 11:07:33.225: E/AndroidRuntime(238):  at android.widget.AdapterView.performItemClick(AdapterView.java:284)
02-13 11:07:33.225: E/AndroidRuntime(238):  at android.widget.ListView.performItemClick(ListView.java:3285)
02-13 11:07:33.225: E/AndroidRuntime(238):  at android.widget.AbsListView$PerformClick.run(AbsListView.java:1640)
02-13 11:07:33.225: E/AndroidRuntime(238):  at android.os.Handler.handleCallback(Handler.java:587)
02-13 11:07:33.225: E/AndroidRuntime(238):  at android.os.Handler.dispatchMessage(Handler.java:92)
02-13 11:07:33.225: E/AndroidRuntime(238):  at android.os.Looper.loop(Looper.java:123)
02-13 11:07:33.225: E/AndroidRuntime(238):  at android.app.ActivityThread.main(ActivityThread.java:4363)
02-13 11:07:33.225: E/AndroidRuntime(238):  at java.lang.reflect.Method.invokeNative(Native Method)
02-13 11:07:33.225: E/AndroidRuntime(238):  at java.lang.reflect.Method.invoke(Method.java:521)
02-13 11:07:33.225: E/AndroidRuntime(238):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
02-13 11:07:33.225: E/AndroidRuntime(238):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
02-13 11:07:33.225: E/AndroidRuntime(238):  at dalvik.system.NativeStart.main(Native Method)

我使用的是Android 1.5。我没有在清单中放入特定条目。 有没有想法或其他方法来调用我的市场页面?

3 个答案:

答案 0 :(得分:3)

扩展上一条评论,您可以检查是否可以在设备上解析Intent,然后使用以下代码启动新的Activity:

    PackageManager pm = context.getPackageManager();
    ComponentName cn = intent.resolveActivity(pm);
    if (cn != null) {
        this.startActivity(intent);
    }

答案 1 :(得分:1)

尝试在您的意图中添加以下单位。

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

答案 2 :(得分:0)

如果您在模拟器上运行此代码,您应该知道模拟器上没有Android Market应用程序,因此它会抛出此异常。大多数真实设备应该没有问题。希望这会有所帮助。