我正在使用以下代码使用Android的来电屏幕的应用程序:
Intent inCallIntent = new Intent();
inCallIntent.setClassName("com.android.phone", "com.android.phone.InCallScreen");
startActivity(inCallIntent);
但我收到了以下错误:
10-03 17:23:30.802: ERROR/AndroidRuntime(1495): java.lang.RuntimeException: Error receiving broadcast Intent { act=...alarmservice flg=0x4 (has extras) } in ...CallMeSoon$2@44635330
10-03 17:23:30.802: ERROR/AndroidRuntime(1495): at android.app.ActivityThread$PackageInfo$ReceiverDispatcher$Args.run(ActivityThread.java:771)
10-03 17:23:30.802: ERROR/AndroidRuntime(1495): at android.os.Handler.handleCallback(Handler.java:609)
10-03 17:23:30.802: ERROR/AndroidRuntime(1495): at android.os.Handler.dispatchMessage(Handler.java:92)
10-03 17:23:30.802: ERROR/AndroidRuntime(1495): at android.os.Looper.loop(Looper.java:123)
10-03 17:23:30.802: ERROR/AndroidRuntime(1495): at android.app.ActivityThread.main(ActivityThread.java:4595)
10-03 17:23:30.802: ERROR/AndroidRuntime(1495): at java.lang.reflect.Method.invokeNative(Native Method)
10-03 17:23:30.802: ERROR/AndroidRuntime(1495): at java.lang.reflect.Method.invoke(Method.java:521)
10-03 17:23:30.802: ERROR/AndroidRuntime(1495): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
10-03 17:23:30.802: ERROR/AndroidRuntime(1495): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
10-03 17:23:30.802: ERROR/AndroidRuntime(1495): at dalvik.system.NativeStart.main(Native Method)
10-03 17:23:30.802: ERROR/AndroidRuntime(1495): Caused by: java.lang.SecurityException: Permission Denial: starting Intent { cmp=com.android.phone/.InCallScreen } from ProcessRecord{449ae8e0 1495:....callmesoon/10099} (pid=1495, uid=10099) requires null
10-03 17:23:30.802: ERROR/AndroidRuntime(1495): at android.os.Parcel.readException(Parcel.java:1218)
10-03 17:23:30.802: ERROR/AndroidRuntime(1495): at android.os.Parcel.readException(Parcel.java:1206)
10-03 17:23:30.802: ERROR/AndroidRuntime(1495): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1226)
10-03 17:23:30.802: ERROR/AndroidRuntime(1495): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1373)
10-03 17:23:30.802: ERROR/AndroidRuntime(1495): at android.app.Activity.startActivityForResult(Activity.java:2789)
10-03 17:23:30.802: ERROR/AndroidRuntime(1495): at android.app.Activity.startActivity(Activity.java:2895)
10-03 17:23:30.802: ERROR/AndroidRuntime(1495): at ....CallMeSoon$2.onReceive(CallMeSoon.java:304)
10-03 17:23:30.802: ERROR/AndroidRuntime(1495): at android.app.ActivityThread$PackageInfo$ReceiverDispatcher$Args.run(ActivityThread.java:760)
10-03 17:23:30.802: ERROR/AndroidRuntime(1495): ... 9 more
我知道错过了某处的许可。但是可能是什么?
更新:许可不是 android.permission.CALL_PHONE 也不 android.permission.CALL_PRIVILEGED
答案 0 :(得分:1)
引起:java.lang.SecurityException:Permission Denial:从ProcessRecord {449ae8e0 1495:.... callmesoon / 10099}启动Intent {cmp = com.android.phone / .InCallScreen}(pid = 1495,uid = 10099)需要null
这是根本原因,它是由于应用程序Manifestfile中的应用程序组件的双重输入而产生的。您可能已在清单文件中多次声明InCallScreen活动。 请仔细检查一下。!!
答案 1 :(得分:0)
将此添加到AndroidManifest.xml
android.permission.CALL_PHONE
或
android.permission.CALL_PRIVILEGED
您也不会错过通常拨打的电话号码,您可以在意图数据中设置此号码。如果您想打电话或使用其他Intent actions
,您需要像这样设置您的意图Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:+15554441212"));
startActivity(intent);