0

我正在使用 cocos2d 开发游戏应用程序。我想用 ACTION_VIEW 注册 data content://mocha/gameID/reset
我的清单文件:

<intent-filter >
        <action android:name="android.intent.action.VIEW" />
        <data android:scheme="content://mocha/gameID/reset"/>
    </intent-filter>

这是我的代码

@Override
public void onPause() {
    super.onPause();
    GamebarLayer.gamestart = false;
    Constants.gameOver     = false;
    CCDirector.sharedDirector().pause();
    Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW); 
    myIntent.setData(Uri.parse("content://mocha/gameID/reset"));
    startActivity(myIntent);
}

这是结果:

02-01 09:27:45.308: E/AndroidRuntime(395): FATAL EXCEPTION: main
02-01 09:27:45.308: E/AndroidRuntime(395): java.lang.RuntimeException: Unable to pause activity {ihpc.mocha/ihpc.mocha.MainScene}: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=content://mocha/gameID/reset }
02-01 09:27:45.308: E/AndroidRuntime(395):  at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2487)
02-01 09:27:45.308: E/AndroidRuntime(395):  at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2444)
02-01 09:27:45.308: E/AndroidRuntime(395):  at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:2422)
02-01 09:27:45.308: E/AndroidRuntime(395):  at android.app.ActivityThread.access$1700(ActivityThread.java:122)
02-01 09:27:45.308: E/AndroidRuntime(395):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1013)
02-01 09:27:45.308: E/AndroidRuntime(395):  at android.os.Handler.dispatchMessage(Handler.java:99)
02-01 09:27:45.308: E/AndroidRuntime(395):  at android.os.Looper.loop(Looper.java:132)
02-01 09:27:45.308: E/AndroidRuntime(395):  at android.app.ActivityThread.main(ActivityThread.java:4025)
02-01 09:27:45.308: E/AndroidRuntime(395):  at java.lang.reflect.Method.invokeNative(Native Method)
02-01 09:27:45.308: E/AndroidRuntime(395):  at java.lang.reflect.Method.invoke(Method.java:491)
02-01 09:27:45.308: E/AndroidRuntime(395):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
02-01 09:27:45.308: E/AndroidRuntime(395):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
02-01 09:27:45.308: E/AndroidRuntime(395):  at dalvik.system.NativeStart.main(Native Method)
02-01 09:27:45.308: E/AndroidRuntime(395): Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=content://mocha/gameID/reset }
02-01 09:27:45.308: E/AndroidRuntime(395):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1508)
02-01 09:27:45.308: E/AndroidRuntime(395):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1382)
02-01 09:27:45.308: E/AndroidRuntime(395):  at android.app.Activity.startActivityForResult(Activity.java:3095)
02-01 09:27:45.308: E/AndroidRuntime(395):  at android.app.Activity.startActivity(Activity.java:3201)
02-01 09:27:45.308: E/AndroidRuntime(395):  at ihpc.mocha.MainScene.onPause(MainScene.java:76)
02-01 09:27:45.308: E/AndroidRuntime(395):  at android.app.Activity.performPause(Activity.java:4452)
02-01 09:27:45.308: E/AndroidRuntime(395):  at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1194)
02-01 09:27:45.308: E/AndroidRuntime(395):  at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2474)
02-01 09:27:45.308: E/AndroidRuntime(395):  ... 12 more
4

1 回答 1

0

如果您要开始自己的活动,那么就这样做。

Intent intent = new Intent(this, OtherActivity.class);
Intent.setData(...);
StartActivity(intent);

http://developer.android.com/reference/android/content/Intent.html

于 2013-02-01T04:20:10.113 回答