基本上我有与如何在 Android 上实现我自己的 URI 方案中描述的相同的问题
我按照已回答问题中的说明添加到我的 android 清单中:
<activity android:name=".MyUriActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="myapp" android:host="path" />
</intent-filter>
</activity>
另外,我添加了一个这样的新活动:
import android.app.Activity;
import android.os.Bundle;
public class MyUriActivity extends Activity {
@Override
public void onCreate(Bundle b){
System.out.println("URI CLICKED!");
}
}
我的 Android 应用基于 Phonegap,所以我只是添加了一个指向我的 index.html 的链接,如下所示:
<a href="myapp://foo">Click me</a>
当我单击时,我在控制台中看到以下错误:
03-14 12:23:16.177: E/Cordova(629): Error loading url myapp://foo
03-14 12:23:16.177: E/Cordova(629): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=myapp://foo }
03-14 12:23:16.177: E/Cordova(629): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1545)
03-14 12:23:16.177: E/Cordova(629): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1416)
03-14 12:23:16.177: E/Cordova(629): at android.app.Activity.startActivityForResult(Activity.java:3351)
03-14 12:23:16.177: E/Cordova(629): at android.app.Activity.startActivityForResult(Activity.java:3312)
03-14 12:23:16.177: E/Cordova(629): at android.app.Activity.startActivity(Activity.java:3522)
03-14 12:23:16.177: E/Cordova(629): at android.app.Activity.startActivity(Activity.java:3490)
03-14 12:23:16.177: E/Cordova(629): at org.apache.cordova.CordovaWebViewClient.shouldOverrideUrlLoading(CordovaWebViewClient.java:209)
03-14 12:23:16.177: E/Cordova(629): at android.webkit.CallbackProxy.uiOverrideUrlLoading(CallbackProxy.java:274)
03-14 12:23:16.177: E/Cordova(629): at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:376)
03-14 12:23:16.177: E/Cordova(629): at android.os.Handler.dispatchMessage(Handler.java:99)
03-14 12:23:16.177: E/Cordova(629): at android.os.Looper.loop(Looper.java:137)
03-14 12:23:16.177: E/Cordova(629): at android.app.ActivityThread.main(ActivityThread.java:4745)
03-14 12:23:16.177: E/Cordova(629): at java.lang.reflect.Method.invokeNative(Native Method)
03-14 12:23:16.177: E/Cordova(629): at java.lang.reflect.Method.invoke(Method.java:511)
03-14 12:23:16.177: E/Cordova(629): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
03-14 12:23:16.177: E/Cordova(629): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
03-14 12:23:16.177: E/Cordova(629): at dalvik.system.NativeStart.main(Native Method)
所以我好像错过了这个活动。怎么了?