简体   繁体   中英

Can not use new Android 4.0 VpnService framework

I'm trying to use the new Android 4.0 VPN framework with the Emulator.

In my sample app I'm calling:

 Intent intent = VpnService.prepare(SimpleVpnActivity.this);
 if(null != intent){
     startActivityForResult(intent, 1);
 }

But the application crashes with an exception because the VpnService.prepare() returns an explicit intent: Intent: { cmp=com.android.vpndialogs/.ConfirmDialog } for activity which can't be found by startActivityForResult().

Am I doing something wrong?

I would appreciate any help.

Here my stack dump:

E/AndroidRuntime(12783): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.vpndialogs/ 
com.android.vpndialogs.ConfirmDialog}; have you declared this activity in your AndroidManifest.xml? 
E/AndroidRuntime(12783):        at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1508) 
E/AndroidRuntime(12783):        at android.app.Instrumentation.execStartActivity(Instrumentation.java: 1384) 
E/AndroidRuntime(12783):        at android.app.Activity.startActivityForResult(Activity.java:3190) 
E/AndroidRuntime(12783):        at com.my.simple.vpn.SimpleVpnActivity $1.onClick(SimpleVpnActivity.java:30) 
E/AndroidRuntime(12783):        at android.view.View.performClick(View.java: 3460) 
E/AndroidRuntime(12783):        at android.view.View $PerformClick.run(View.java:13955) 
E/AndroidRuntime(12783):        at android.os.Handler.handleCallback(Handler.java:605) 
E/AndroidRuntime(12783):        at android.os.Handler.dispatchMessage(Handler.java:92) 
E/AndroidRuntime(12783):        at android.os.Looper.loop(Looper.java:137) 
E/AndroidRuntime(12783):        at android.app.ActivityThread.main(ActivityThread.java:4340) 
E/AndroidRuntime(12783):        at java.lang.reflect.Method.invokeNative(Native Method) 
E/AndroidRuntime(12783):        at java.lang.reflect.Method.invoke(Method.java:511) 
E/AndroidRuntime(12783):        at com.android.internal.os.ZygoteInit $MethodAndArgsCaller.run(ZygoteInit.java:784) 
E/AndroidRuntime(12783):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 
E/AndroidRuntime(12783):        at dalvik.system.NativeStart.main(Native Method)

It looks like the com.android.vpndialogs package isn't being built as part of the emulator image. That's a bug that the SDK team will need to fix.

I'd say to file a bug on b.android.com, but it looks like you've already done that and it's being investigated. :)

Reference: http://code.google.com/p/android/issues/detail?id=21030

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM