我正在尝试通过将包名称传递给Intent来将联系人导出到SD卡,如下所示
Intent i = new Intent();
i.setComponent(new ComponentName("com.android.contacts",
"com.android.contacts.ExportVCardActivity"));
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
但它在Galaxy Ace和S2中给出了以下例外(我只在这些设备上试过)
11-04 12:37:05.808:W / System.err(3461):java.lang.SecurityException:Permission Denial:从ProcessRecord {启动Intent {flg = 0x10000000 cmp = com.android.contacts / .ExportVCardActivity} { 40710c10 3461:com.ImpExp / 10060}(pid = 3461,uid = 10060)需要null 11-04 12:37:05.816:W / System.err(3461):在android.os.Parcel.readException(Parcel.java:1322) 11-04 12:37:05.820:W / System.err(3461):在android.os.Parcel.readException(Parcel.java:1276) 11-04 12:37:05.820:W / System.err(3461):在android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1351) 11-04 12:37:05.824:W / System.err(3461):在android.app.Instrumentation.execStartActivity(Instrumentation.java:1374) 11-04 12:37:05.828:W / System.err(3461):在android.app.Activity.startActivityForResult(Activity.java:2827) 11-04 12:37:05.832:W / System.err(3461):在android.app.Activity.startActivity(Activity.java:2933) 11-04 12:37:05.832:W / System.err(3461):at com.ImpExp.ImpExp $ 4.onClick(ImpExp.java:74) 11-04 12:37:05.832:W / System.err(3461):在android.view.View.performClick(View.java:2485) 11-04 12:37:05.832:W / System.err(3461):在android.view.View $ PerformClick.run(View.java:9080) 11-04 12:37:05.832:W / System.err(3461):在android.os.Handler.handleCallback(Handler.java:587) 11-04 12:37:05.832:W / System.err(3461):在android.os.Handler.dispatchMessage(Handler.java:92) 11-04 12:37:05.832:W / System.err(3461):在android.os.Looper.loop(Looper.java:130) 11-04 12:37:05.832:W / System.err(3461):在android.app.ActivityThread.main(ActivityThread.java:3683) 11-04 12:37:05.832:W / System.err(3461):at java.lang.reflect.Method.invokeNative(Native Method) 11-04 12:37:05.832:W / System.err(3461):at java.lang.reflect.Method.invoke(Method.java:507) 11-04 12:37:05.835:W / System.err(3461):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:839) 11-04 12:37:05.835:W / System.err(3461):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 11-04 12:37:05.835:W / System.err(3461):at dalvik.system.NativeStart.main(Native Method)
我给了
android.permission.READ_CONTACTS“和
android.permission.WRITE_EXTERNAL_STORAGE“
即使它崩溃了,任何想法我需要什么样的许可或任何其他方式也赞赏。
答案 0 :(得分:1)
您是否必须在manifest.xml文件中声明活动?