private void sendSMS(String phoneNumber, String message) {
PendingIntent pi = PendingIntent.getActivity(this, 0,
new Intent(this, Msgactivity.class), 0);
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null,message, pi, null);
}
在上面的代码执行sms.sendTextMessage(phoneNumber, null,message, pi, null);
语句时,我的应用程序显示“应用程序示例已意外停止”消息。
我添加了清单文件的用户权限
该消息的原因是什么?
LogCat输出是 -
09-05 15:39:11.758: DEBUG/AndroidRuntime(403): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
09-05 15:39:11.758: DEBUG/AndroidRuntime(403): CheckJNI is ON
09-05 15:39:12.648: DEBUG/AndroidRuntime(403): Calling main entry com.android.commands.pm.Pm
09-05 15:39:12.678: DEBUG/AndroidRuntime(403): Shutting down VM
09-05 15:39:12.698: DEBUG/dalvikvm(403): GC_CONCURRENT freed 101K, 71% free 297K/1024K, external 0K/0K, paused 1ms+1ms
09-05 15:39:12.708: DEBUG/dalvikvm(403): Debugger has detached; object registry had 1 entries
09-05 15:39:12.739: INFO/AndroidRuntime(403): NOTE: attach of thread 'Binder Thread #3' failed
09-05 15:39:13.328: DEBUG/AndroidRuntime(413): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
09-05 15:39:13.328: DEBUG/AndroidRuntime(413): CheckJNI is ON
09-05 15:39:14.188: DEBUG/AndroidRuntime(413): Calling main entry com.android.commands.am.Am
09-05 15:39:14.228: INFO/ActivityManager(70): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=task.list/.DolistActivity } from pid 413
09-05 15:39:14.308: DEBUG/AndroidRuntime(413): Shutting down VM
09-05 15:39:14.318: DEBUG/dalvikvm(413): GC_CONCURRENT freed 102K, 69% free 319K/1024K, external 0K/0K, paused 1ms+1ms
09-05 15:39:14.328: DEBUG/dalvikvm(413): Debugger has detached; object registry had 1 entries
09-05 15:39:14.428: INFO/AndroidRuntime(413): NOTE: attach of thread 'Binder Thread #3' failed
09-05 15:39:15.138: INFO/ActivityManager(70): Displayed task.list/.DolistActivity: +877ms
09-05 15:39:20.599: DEBUG/dalvikvm(138): GC_EXPLICIT freed 57K, 49% free 3059K/5959K, external 1625K/2102K, paused 68ms
09-05 15:39:21.879: INFO/ActivityManager(70): Starting: Intent { cmp=task.list/.Msgactivity } from pid 374
09-05 15:39:22.349: INFO/ActivityManager(70): Displayed task.list/.Msgactivity: +457ms
09-05 15:39:27.319: WARN/KeyCharacterMap(120): No keyboard for id 0
09-05 15:39:27.319: WARN/KeyCharacterMap(120): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
09-05 15:39:31.968: DEBUG/AndroidRuntime(374): Shutting down VM
09-05 15:39:31.968: WARN/dalvikvm(374): threadid=1: thread exiting with uncaught exception (group=0x40015560)
09-05 15:39:31.988: ERROR/AndroidRuntime(374): FATAL EXCEPTION: main
09-05 15:39:31.988: ERROR/AndroidRuntime(374): java.lang.IllegalArgumentException: Invalid destinationAddress
09-05 15:39:31.988: ERROR/AndroidRuntime(374): at android.telephony.SmsManager.sendTextMessage(SmsManager.java:77)
09-05 15:39:31.988: ERROR/AndroidRuntime(374): at task.list.Msgactivity.sendSMS(Msgactivity.java:51)
09-05 15:39:31.988: ERROR/AndroidRuntime(374): at task.list.Msgactivity.access$0(Msgactivity.java:46)
09-05 15:39:31.988: ERROR/AndroidRuntime(374): at task.list.Msgactivity$1.onClick(Msgactivity.java:38)
09-05 15:39:31.988: ERROR/AndroidRuntime(374): at android.view.View.performClick(View.java:2485)
09-05 15:39:31.988: ERROR/AndroidRuntime(374): at android.view.View$PerformClick.run(View.java:9080)
09-05 15:39:31.988: ERROR/AndroidRuntime(374): at android.os.Handler.handleCallback(Handler.java:587)
09-05 15:39:31.988: ERROR/AndroidRuntime(374): at android.os.Handler.dispatchMessage(Handler.java:92)
09-05 15:39:31.988: ERROR/AndroidRuntime(374): at android.os.Looper.loop(Looper.java:123)
09-05 15:39:31.988: ERROR/AndroidRuntime(374): at android.app.ActivityThread.main(ActivityThread.java:3683)
09-05 15:39:31.988: ERROR/AndroidRuntime(374): at java.lang.reflect.Method.invokeNative(Native Method)
09-05 15:39:31.988: ERROR/AndroidRuntime(374): at java.lang.reflect.Method.invoke(Method.java:507)
09-05 15:39:31.988: ERROR/AndroidRuntime(374): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-05 15:39:31.988: ERROR/AndroidRuntime(374): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-05 15:39:31.988: ERROR/AndroidRuntime(374): at dalvik.system.NativeStart.main(Native Method)
09-05 15:39:31.998: WARN/ActivityManager(70): Force finishing activity task.list/.Msgactivity
09-05 15:39:32.528: WARN/ActivityManager(70): Activity pause timeout for HistoryRecord{406a9190 task.list/.Msgactivity}
09-05 15:39:32.698: INFO/dalvikvm(70): Jit: resizing JitTable from 1024 to 2048
09-05 15:39:34.609: INFO/Process(374): Sending signal. PID: 374 SIG: 9
09-05 15:39:34.629: INFO/ActivityManager(70): Process task.list (pid 374) has died.
09-05 15:39:34.649: ERROR/InputDispatcher(70): channel '406de700 task.list/task.list.DolistActivity (server)' ~ Consumer closed input channel or an error
occurred. events=0x8
09-05 15:39:34.649: ERROR/InputDispatcher(70): channel '406de700 task.list/task.list.DolistActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
09-05 15:39:34.678: INFO/WindowManager(70): WIN DEATH: Window{406de700 task.list/task.list.DolistActivity paused=false}
09-05 15:39:34.729: INFO/WindowManager(70): WIN DEATH: Window{40713818 task.list/task.list.Msgactivity paused=false}
09-05 15:39:34.799: ERROR/InputDispatcher(70): Received spurious receive callback for unknown input channel. fd=162, events=0x8
09-05 15:39:35.089: WARN/InputManagerService(70): Got RemoteException sending setActive(false) notification to pid 374 uid 10043
提前致谢
答案 0 :(得分:3)
09-05 15:39:31.988:ERROR / AndroidRuntime(374):致命异常:主
09-05 15:39:31.988:ERROR / AndroidRuntime(374): java.lang.IllegalArgumentException:无效的destinationAddress
这就是原因。 “无效的destinationAddress”