android parcel读取异常

时间:2012-10-09 05:12:58

标签: android

这是this one 的后续问题 我得到以下堆栈logcat包裹读取ecception为什么我得到这个

 10-09 10:27:27.993: I/dalvikvm(825): threadid=3: reacting to signal 3
10-09 10:27:28.093: I/dalvikvm(825): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:27:28.422: D/gralloc_goldfish(825): Emulator without GPU emulation detected.
10-09 10:28:45.692: W/ActivityThread(872): Application com.example.sms is waiting for the debugger on port 8100...
10-09 10:28:45.793: I/System.out(872): Sending WAIT chunk
10-09 10:28:45.813: I/dalvikvm(872): Debugger is active
10-09 10:28:45.833: I/System.out(872): Debugger has connected
10-09 10:28:45.853: I/System.out(872): waiting for debugger to settle...
10-09 10:28:46.063: I/System.out(872): waiting for debugger to settle...
10-09 10:28:46.263: I/System.out(872): waiting for debugger to settle...
10-09 10:28:46.273: I/dalvikvm(872): threadid=3: reacting to signal 3
10-09 10:28:46.312: I/dalvikvm(872): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:28:46.462: I/System.out(872): waiting for debugger to settle...
10-09 10:28:46.662: I/System.out(872): waiting for debugger to settle...
10-09 10:28:46.783: I/dalvikvm(872): threadid=3: reacting to signal 3
10-09 10:28:46.793: I/dalvikvm(872): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:28:46.863: I/System.out(872): waiting for debugger to settle...
10-09 10:28:47.072: I/System.out(872): waiting for debugger to settle...
10-09 10:28:47.263: I/dalvikvm(872): threadid=3: reacting to signal 3
10-09 10:28:47.293: I/System.out(872): waiting for debugger to settle...
10-09 10:28:47.293: I/dalvikvm(872): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:28:47.492: I/System.out(872): waiting for debugger to settle...
10-09 10:28:47.692: I/System.out(872): waiting for debugger to settle...
10-09 10:28:47.763: I/dalvikvm(872): threadid=3: reacting to signal 3
10-09 10:28:47.773: I/dalvikvm(872): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:28:47.893: I/System.out(872): waiting for debugger to settle...
10-09 10:28:48.100: I/System.out(872): debugger has settled (1441)
10-09 10:28:48.273: I/dalvikvm(872): threadid=3: reacting to signal 3
10-09 10:28:48.402: I/dalvikvm(872): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:28:48.773: I/dalvikvm(872): threadid=3: reacting to signal 3
10-09 10:28:48.813: I/dalvikvm(872): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:28:49.213: D/gralloc_goldfish(872): Emulator without GPU emulation detected.
10-09 10:28:49.282: I/dalvikvm(872): threadid=3: reacting to signal 3
10-09 10:28:49.322: I/dalvikvm(872): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:29:00.063: D/AndroidRuntime(872): Shutting down VM
10-09 10:29:00.063: W/dalvikvm(872): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
10-09 10:29:00.203: E/AndroidRuntime(872): FATAL EXCEPTION: main
10-09 10:29:00.203: E/AndroidRuntime(872): java.lang.NullPointerException
10-09 10:29:00.203: E/AndroidRuntime(872):  at android.os.Parcel.readException(Parcel.java:1333)
10-09 10:29:00.203: E/AndroidRuntime(872):  at android.os.Parcel.readException(Parcel.java:1281)
10-09 10:29:00.203: E/AndroidRuntime(872):  at com.android.internal.telephony.ISms$Stub$Proxy.sendText(ISms.java:413)
10-09 10:29:00.203: E/AndroidRuntime(872):  at android.telephony.SmsManager.sendTextMessage(SmsManager.java:87)
10-09 10:29:00.203: E/AndroidRuntime(872):  at com.example.sms.SendSMSActivity.sendSMS(SendSMSActivity.java:134)
10-09 10:29:00.203: E/AndroidRuntime(872):  at com.example.sms.SendSMSActivity.access$0(SendSMSActivity.java:74)
10-09 10:29:00.203: E/AndroidRuntime(872):  at com.example.sms.SendSMSActivity$1.onClick(SendSMSActivity.java:59)
10-09 10:29:00.203: E/AndroidRuntime(872):  at android.view.View.performClick(View.java:3511)
10-09 10:29:00.203: E/AndroidRuntime(872):  at android.view.View$PerformClick.run(View.java:14105)
10-09 10:29:00.203: E/AndroidRuntime(872):  at android.os.Handler.handleCallback(Handler.java:605)
10-09 10:29:00.203: E/AndroidRuntime(872):  at android.os.Handler.dispatchMessage(Handler.java:92)
10-09 10:29:00.203: E/AndroidRuntime(872):  at android.os.Looper.loop(Looper.java:137)
10-09 10:29:00.203: E/AndroidRuntime(872):  at android.app.ActivityThread.main(ActivityThread.java:4424)
10-09 10:29:00.203: E/AndroidRuntime(872):  at java.lang.reflect.Method.invokeNative(Native Method)
10-09 10:29:00.203: E/AndroidRuntime(872):  at java.lang.reflect.Method.invoke(Method.java:511)
10-09 10:29:00.203: E/AndroidRuntime(872):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-09 10:29:00.203: E/AndroidRuntime(872):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-09 10:29:00.203: E/AndroidRuntime(872):  at dalvik.system.NativeStart.main(Native Method)
10-09 10:29:00.803: I/dalvikvm(872): threadid=3: reacting to signal 3
10-09 10:29:00.823: I/dalvikvm(872): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:29:48.632: I/dalvikvm(920): threadid=3: reacting to signal 3
10-09 10:29:48.793: I/dalvikvm(920): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:29:49.133: I/dalvikvm(920): threadid=3: reacting to signal 3
10-09 10:29:49.173: I/dalvikvm(920): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:29:49.203: D/gralloc_goldfish(920): Emulator without GPU emulation detected.
10-09 10:30:34.003: W/ActivityThread(960): Application com.example.sms is waiting for the debugger on port 8100...
10-09 10:30:34.093: I/System.out(960): Sending WAIT chunk
10-09 10:30:34.103: I/dalvikvm(960): Debugger is active
10-09 10:30:34.113: I/System.out(960): Debugger has connected
10-09 10:30:34.163: I/System.out(960): waiting for debugger to settle...
10-09 10:30:34.362: I/System.out(960): waiting for debugger to settle...
10-09 10:30:34.432: I/dalvikvm(960): threadid=3: reacting to signal 3
10-09 10:30:34.442: I/dalvikvm(960): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:30:34.562: I/System.out(960): waiting for debugger to settle...
10-09 10:30:34.763: I/System.out(960): waiting for debugger to settle...
10-09 10:30:34.923: I/dalvikvm(960): threadid=3: reacting to signal 3
10-09 10:30:34.933: I/dalvikvm(960): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:30:34.963: I/System.out(960): waiting for debugger to settle...
10-09 10:30:35.170: I/System.out(960): waiting for debugger to settle...
10-09 10:30:35.371: I/System.out(960): waiting for debugger to settle...
10-09 10:30:35.442: I/dalvikvm(960): threadid=3: reacting to signal 3
10-09 10:30:35.462: I/dalvikvm(960): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:30:35.573: I/System.out(960): waiting for debugger to settle...
10-09 10:30:35.773: I/System.out(960): waiting for debugger to settle...
10-09 10:30:35.953: I/dalvikvm(960): threadid=3: reacting to signal 3
10-09 10:30:36.013: I/System.out(960): waiting for debugger to settle...
10-09 10:30:36.013: I/dalvikvm(960): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:30:36.215: I/System.out(960): debugger has settled (1432)
10-09 10:30:36.452: I/dalvikvm(960): threadid=3: reacting to signal 3
10-09 10:30:36.582: I/dalvikvm(960): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:30:36.953: I/dalvikvm(960): threadid=3: reacting to signal 3
10-09 10:30:36.983: I/dalvikvm(960): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:30:37.462: I/dalvikvm(960): threadid=3: reacting to signal 3
10-09 10:30:37.472: I/dalvikvm(960): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:30:37.502: D/gralloc_goldfish(960): Emulator without GPU emulation detected.
10-09 10:31:08.195: D/AndroidRuntime(960): Shutting down VM
10-09 10:31:08.195: W/dalvikvm(960): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
10-09 10:31:08.292: E/AndroidRuntime(960): FATAL EXCEPTION: main
10-09 10:31:08.292: E/AndroidRuntime(960): java.lang.NullPointerException
10-09 10:31:08.292: E/AndroidRuntime(960):  at android.os.Parcel.readException(Parcel.java:1333)
10-09 10:31:08.292: E/AndroidRuntime(960):  at android.os.Parcel.readException(Parcel.java:1281)
10-09 10:31:08.292: E/AndroidRuntime(960):  at com.android.internal.telephony.ISms$Stub$Proxy.sendText(ISms.java:413)
10-09 10:31:08.292: E/AndroidRuntime(960):  at android.telephony.SmsManager.sendTextMessage(SmsManager.java:87)
10-09 10:31:08.292: E/AndroidRuntime(960):  at com.example.sms.SendSMSActivity.sendSMS(SendSMSActivity.java:134)
10-09 10:31:08.292: E/AndroidRuntime(960):  at com.example.sms.SendSMSActivity.access$0(SendSMSActivity.java:74)
10-09 10:31:08.292: E/AndroidRuntime(960):  at com.example.sms.SendSMSActivity$1.onClick(SendSMSActivity.java:57)
10-09 10:31:08.292: E/AndroidRuntime(960):  at android.view.View.performClick(View.java:3511)
10-09 10:31:08.292: E/AndroidRuntime(960):  at android.view.View$PerformClick.run(View.java:14105)
10-09 10:31:08.292: E/AndroidRuntime(960):  at android.os.Handler.handleCallback(Handler.java:605)
10-09 10:31:08.292: E/AndroidRuntime(960):  at android.os.Handler.dispatchMessage(Handler.java:92)
10-09 10:31:08.292: E/AndroidRuntime(960):  at android.os.Looper.loop(Looper.java:137)
10-09 10:31:08.292: E/AndroidRuntime(960):  at android.app.ActivityThread.main(ActivityThread.java:4424)
10-09 10:31:08.292: E/AndroidRuntime(960):  at java.lang.reflect.Method.invokeNative(Native Method)
10-09 10:31:08.292: E/AndroidRuntime(960):  at java.lang.reflect.Method.invoke(Method.java:511)
10-09 10:31:08.292: E/AndroidRuntime(960):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-09 10:31:08.292: E/AndroidRuntime(960):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-09 10:31:08.292: E/AndroidRuntime(960):  at dalvik.system.NativeStart.main(Native Method)
10-09 10:31:08.913: I/dalvikvm(960): threadid=3: reacting to signal 3
10-09 10:31:08.923: I/dalvikvm(960): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:31:11.983: I/Process(960): Sending signal. PID: 960 SIG: 9
10-09 10:31:28.392: I/dalvikvm(1008): threadid=3: reacting to signal 3
10-09 10:31:28.492: I/dalvikvm(1008): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:31:28.843: D/gralloc_goldfish(1008): Emulator without GPU emulation detected.
10-09 10:31:32.713: D/AndroidRuntime(1008): Shutting down VM
10-09 10:31:32.713: W/dalvikvm(1008): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
10-09 10:31:32.803: E/AndroidRuntime(1008): FATAL EXCEPTION: main
10-09 10:31:32.803: E/AndroidRuntime(1008): java.lang.NullPointerException
10-09 10:31:32.803: E/AndroidRuntime(1008):     at android.os.Parcel.readException(Parcel.java:1333)
10-09 10:31:32.803: E/AndroidRuntime(1008):     at android.os.Parcel.readException(Parcel.java:1281)
10-09 10:31:32.803: E/AndroidRuntime(1008):     at com.android.internal.telephony.ISms$Stub$Proxy.sendText(ISms.java:413)
10-09 10:31:32.803: E/AndroidRuntime(1008):     at android.telephony.SmsManager.sendTextMessage(SmsManager.java:87)
10-09 10:31:32.803: E/AndroidRuntime(1008):     at com.example.sms.SendSMSActivity.sendSMS(SendSMSActivity.java:134)
10-09 10:31:32.803: E/AndroidRuntime(1008):     at com.example.sms.SendSMSActivity.access$0(SendSMSActivity.java:74)
10-09 10:31:32.803: E/AndroidRuntime(1008):     at com.example.sms.SendSMSActivity$1.onClick(SendSMSActivity.java:57)
10-09 10:31:32.803: E/AndroidRuntime(1008):     at android.view.View.performClick(View.java:3511)
10-09 10:31:32.803: E/AndroidRuntime(1008):     at android.view.View$PerformClick.run(View.java:14105)
10-09 10:31:32.803: E/AndroidRuntime(1008):     at android.os.Handler.handleCallback(Handler.java:605)
10-09 10:31:32.803: E/AndroidRuntime(1008):     at android.os.Handler.dispatchMessage(Handler.java:92)
10-09 10:31:32.803: E/AndroidRuntime(1008):     at android.os.Looper.loop(Looper.java:137)
10-09 10:31:32.803: E/AndroidRuntime(1008):     at android.app.ActivityThread.main(ActivityThread.java:4424)
10-09 10:31:32.803: E/AndroidRuntime(1008):     at java.lang.reflect.Method.invokeNative(Native Method)
10-09 10:31:32.803: E/AndroidRuntime(1008):     at java.lang.reflect.Method.invoke(Method.java:511)
10-09 10:31:32.803: E/AndroidRuntime(1008):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-09 10:31:32.803: E/AndroidRuntime(1008):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-09 10:31:32.803: E/AndroidRuntime(1008):     at dalvik.system.NativeStart.main(Native Method)
10-09 10:31:33.392: I/dalvikvm(1008): threadid=3: reacting to signal 3
10-09 10:31:33.402: I/dalvikvm(1008): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:32:10.452: I/dalvikvm(1055): threadid=3: reacting to signal 3
10-09 10:32:10.523: I/dalvikvm(1055): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:32:10.923: D/gralloc_goldfish(1055): Emulator without GPU emulation detected.
10-09 10:32:10.953: I/dalvikvm(1055): threadid=3: reacting to signal 3
10-09 10:32:10.973: I/dalvikvm(1055): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:35:10.863: D/AndroidRuntime(1055): Shutting down VM
10-09 10:35:10.863: W/dalvikvm(1055): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
10-09 10:35:10.883: E/AndroidRuntime(1055): FATAL EXCEPTION: main
10-09 10:35:10.883: E/AndroidRuntime(1055): java.lang.NullPointerException
10-09 10:35:10.883: E/AndroidRuntime(1055):     at android.os.Parcel.readException(Parcel.java:1333)
10-09 10:35:10.883: E/AndroidRuntime(1055):     at android.os.Parcel.readException(Parcel.java:1281)
10-09 10:35:10.883: E/AndroidRuntime(1055):     at com.android.internal.telephony.ISms$Stub$Proxy.sendText(ISms.java:413)
10-09 10:35:10.883: E/AndroidRuntime(1055):     at android.telephony.SmsManager.sendTextMessage(SmsManager.java:87)
10-09 10:35:10.883: E/AndroidRuntime(1055):     at com.example.sms.SendSMSActivity.sendSMS(SendSMSActivity.java:132)
10-09 10:35:10.883: E/AndroidRuntime(1055):     at com.example.sms.SendSMSActivity.access$0(SendSMSActivity.java:72)
10-09 10:35:10.883: E/AndroidRuntime(1055):     at com.example.sms.SendSMSActivity$1.onClick(SendSMSActivity.java:57)
10-09 10:35:10.883: E/AndroidRuntime(1055):     at android.view.View.performClick(View.java:3511)
10-09 10:35:10.883: E/AndroidRuntime(1055):     at android.view.View$PerformClick.run(View.java:14105)
10-09 10:35:10.883: E/AndroidRuntime(1055):     at android.os.Handler.handleCallback(Handler.java:605)
10-09 10:35:10.883: E/AndroidRuntime(1055):     at android.os.Handler.dispatchMessage(Handler.java:92)
10-09 10:35:10.883: E/AndroidRuntime(1055):     at android.os.Looper.loop(Looper.java:137)
10-09 10:35:10.883: E/AndroidRuntime(1055):     at android.app.ActivityThread.main(ActivityThread.java:4424)
10-09 10:35:10.883: E/AndroidRuntime(1055):     at java.lang.reflect.Method.invokeNative(Native Method)
10-09 10:35:10.883: E/AndroidRuntime(1055):     at java.lang.reflect.Method.invoke(Method.java:511)
10-09 10:35:10.883: E/AndroidRuntime(1055):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-09 10:35:10.883: E/AndroidRuntime(1055):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-09 10:35:10.883: E/AndroidRuntime(1055):     at dalvik.system.NativeStart.main(Native Method)
10-09 10:35:11.453: I/dalvikvm(1055): threadid=3: reacting to signal 3
10-09 10:35:11.473: I/dalvikvm(1055): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:35:50.673: I/dalvikvm(1104): threadid=3: reacting to signal 3
10-09 10:35:50.803: I/dalvikvm(1104): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:35:51.112: D/gralloc_goldfish(1104): Emulator without GPU emulation detected.
10-09 10:35:51.142: I/dalvikvm(1104): threadid=3: reacting to signal 3
10-09 10:35:51.182: I/dalvikvm(1104): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:37:12.383: D/AndroidRuntime(1104): Shutting down VM
10-09 10:37:12.383: W/dalvikvm(1104): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
10-09 10:37:12.403: E/AndroidRuntime(1104): FATAL EXCEPTION: main
10-09 10:37:12.403: E/AndroidRuntime(1104): java.lang.NullPointerException
10-09 10:37:12.403: E/AndroidRuntime(1104):     at android.os.Parcel.readException(Parcel.java:1333)
10-09 10:37:12.403: E/AndroidRuntime(1104):     at android.os.Parcel.readException(Parcel.java:1281)
10-09 10:37:12.403: E/AndroidRuntime(1104):     at com.android.internal.telephony.ISms$Stub$Proxy.sendText(ISms.java:413)
10-09 10:37:12.403: E/AndroidRuntime(1104):     at android.telephony.SmsManager.sendTextMessage(SmsManager.java:87)
10-09 10:37:12.403: E/AndroidRuntime(1104):     at com.example.sms.SendSMSActivity.sendSMS(SendSMSActivity.java:132)
10-09 10:37:12.403: E/AndroidRuntime(1104):     at com.example.sms.SendSMSActivity.access$0(SendSMSActivity.java:72)
10-09 10:37:12.403: E/AndroidRuntime(1104):     at com.example.sms.SendSMSActivity$1.onClick(SendSMSActivity.java:57)
10-09 10:37:12.403: E/AndroidRuntime(1104):     at android.view.View.performClick(View.java:3511)
10-09 10:37:12.403: E/AndroidRuntime(1104):     at android.view.View$PerformClick.run(View.java:14105)
10-09 10:37:12.403: E/AndroidRuntime(1104):     at android.os.Handler.handleCallback(Handler.java:605)
10-09 10:37:12.403: E/AndroidRuntime(1104):     at android.os.Handler.dispatchMessage(Handler.java:92)
10-09 10:37:12.403: E/AndroidRuntime(1104):     at android.os.Looper.loop(Looper.java:137)
10-09 10:37:12.403: E/AndroidRuntime(1104):     at android.app.ActivityThread.main(ActivityThread.java:4424)
10-09 10:37:12.403: E/AndroidRuntime(1104):     at java.lang.reflect.Method.invokeNative(Native Method)
10-09 10:37:12.403: E/AndroidRuntime(1104):     at java.lang.reflect.Method.invoke(Method.java:511)
10-09 10:37:12.403: E/AndroidRuntime(1104):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-09 10:37:12.403: E/AndroidRuntime(1104):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-09 10:37:12.403: E/AndroidRuntime(1104):     at dalvik.system.NativeStart.main(Native Method)
10-09 10:37:12.992: I/dalvikvm(1104): threadid=3: reacting to signal 3
10-09 10:37:13.012: I/dalvikvm(1104): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:37:24.783: I/dalvikvm(1169): threadid=3: reacting to signal 3
10-09 10:37:24.882: I/dalvikvm(1169): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:37:25.283: I/dalvikvm(1169): threadid=3: reacting to signal 3
10-09 10:37:25.303: I/dalvikvm(1169): Wrote stack traces to '/data/anr/traces.txt'
10-09 10:37:25.503: D/gralloc_goldfish(1169): Emulator without GPU emulation detected.
10-09 10:37:34.952: W/IInputConnectionWrapper(1169): showStatusIcon on inactive InputConnection
10-09 10:37:45.533: D/AndroidRuntime(1169): Shutting down VM
10-09 10:37:45.533: W/dalvikvm(1169): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
10-09 10:37:45.563: E/AndroidRuntime(1169): FATAL EXCEPTION: main
10-09 10:37:45.563: E/AndroidRuntime(1169): java.lang.NullPointerException
10-09 10:37:45.563: E/AndroidRuntime(1169):     at android.os.Parcel.readException(Parcel.java:1333)
10-09 10:37:45.563: E/AndroidRuntime(1169):     at android.os.Parcel.readException(Parcel.java:1281)
10-09 10:37:45.563: E/AndroidRuntime(1169):     at com.android.internal.telephony.ISms$Stub$Proxy.sendText(ISms.java:413)
10-09 10:37:45.563: E/AndroidRuntime(1169):     at android.telephony.SmsManager.sendTextMessage(SmsManager.java:87)
10-09 10:37:45.563: E/AndroidRuntime(1169):     at com.example.sms.SendSMSActivity.sendSMS(SendSMSActivity.java:132)
10-09 10:37:45.563: E/AndroidRuntime(1169):     at com.example.sms.SendSMSActivity.access$0(SendSMSActivity.java:72)
10-09 10:37:45.563: E/AndroidRuntime(1169):     at com.example.sms.SendSMSActivity$1.onClick(SendSMSActivity.java:57)
10-09 10:37:45.563: E/AndroidRuntime(1169):     at android.view.View.performClick(View.java:3511)
10-09 10:37:45.563: E/AndroidRuntime(1169):     at android.view.View$PerformClick.run(View.java:14105)
10-09 10:37:45.563: E/AndroidRuntime(1169):     at android.os.Handler.handleCallback(Handler.java:605)
10-09 10:37:45.563: E/AndroidRuntime(1169):     at android.os.Handler.dispatchMessage(Handler.java:92)
10-09 10:37:45.563: E/AndroidRuntime(1169):     at android.os.Looper.loop(Looper.java:137)
10-09 10:37:45.563: E/AndroidRuntime(1169):     at android.app.ActivityThread.main(ActivityThread.java:4424)
10-09 10:37:45.563: E/AndroidRuntime(1169):     at java.lang.reflect.Method.invokeNative(Native Method)
10-09 10:37:45.563: E/AndroidRuntime(1169):     at java.lang.reflect.Method.invoke(Method.java:511)
10-09 10:37:45.563: E/AndroidRuntime(1169):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-09 10:37:45.563: E/AndroidRuntime(1169):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-09 10:37:45.563: E/AndroidRuntime(1169):     at dalvik.system.NativeStart.main(Native Method)
10-09 10:37:46.122: I/dalvikvm(1169): threadid=3: reacting to signal 3
10-09 10:37:46.142: I/dalvikvm(1169): Wrote stack traces to '/data/anr/traces.txt'

smsactivity

public class SendSMSActivity extends Activity {

Button btnSendSMS;
EditText txtPhoneNo;
EditText txtMessage;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    btnSendSMS = (Button) findViewById(R.id.btnSendSMS);
    txtPhoneNo = (EditText) findViewById(R.id.txtPhoneNo);
    txtMessage = (EditText) findViewById(R.id.txtMessage);

    btnSendSMS.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            String phoneNo = txtPhoneNo.getText().toString();
            String message = txtMessage.getText().toString();
            if (phoneNo.length() > 0 && message.length() > 0)

            {
                TelephonyManager telMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
                int simState = telMgr.getSimState();
                switch (simState) {
                case TelephonyManager.SIM_STATE_ABSENT:
                    Toast.makeText(getBaseContext(), "No Sim Card found",
                            Toast.LENGTH_SHORT).show();
                    break;
                case TelephonyManager.SIM_STATE_NETWORK_LOCKED:
                    // do something
                    break;
                case TelephonyManager.SIM_STATE_PIN_REQUIRED:
                    // do something
                    break;
                case TelephonyManager.SIM_STATE_PUK_REQUIRED:
                    // do something
                    break;
                case TelephonyManager.SIM_STATE_READY:
                    sendSMS(phoneNo, message); // method to send message
                    break;
                case TelephonyManager.SIM_STATE_UNKNOWN:
                    // do something
                    break;
                }
            } else
                Toast.makeText(getBaseContext(),
                        "Please enter both phone number and message.",
                        Toast.LENGTH_SHORT).show();
        }

        private void sendSMS(String phoneNumber, String message) {
            String SENT = "SMS_SENT";
            String DELIVERED = "SMS_DELIVERED";

            PendingIntent sentPI = PendingIntent.getBroadcast(
                    SendSMSActivity.this, 0, new Intent(SENT), 0);

            PendingIntent deliveredPI = PendingIntent.getBroadcast(
                    SendSMSActivity.this, 0, new Intent(DELIVERED), 0);

            // ---when the SMS has been sent---final String string =
            // "deprecation";
            registerReceiver(new BroadcastReceiver() {

                @Override
                public void onReceive(Context arg0, Intent arg1) {
                    switch (getResultCode()) {
                    case Activity.RESULT_OK:
                        Toast.makeText(SendSMSActivity.this, "SMS sent",
                                Toast.LENGTH_SHORT).show();
                        break;
                    case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
                        Toast.makeText(SendSMSActivity.this,
                                "Generic failure", Toast.LENGTH_SHORT)
                                .show();
                        break;
                    case SmsManager.RESULT_ERROR_NO_SERVICE:
                        Toast.makeText(SendSMSActivity.this, "No service",
                                Toast.LENGTH_SHORT).show();
                        break;
                    case SmsManager.RESULT_ERROR_NULL_PDU:
                        Toast.makeText(SendSMSActivity.this, "Null PDU",
                                Toast.LENGTH_SHORT).show();
                        break;
                    case SmsManager.RESULT_ERROR_RADIO_OFF:
                        Toast.makeText(getBaseContext(), "Radio off",
                                Toast.LENGTH_SHORT).show();
                        break;

                    }
                }
            }, new IntentFilter(SENT));

            // ---when the SMS has been delivered---
            registerReceiver(new BroadcastReceiver() {
                @Override
                public void onReceive(Context arg0, Intent arg1) {
                    switch (getResultCode()) {
                    case Activity.RESULT_OK:
                        Toast.makeText(SendSMSActivity.this,
                                "SMS delivered", Toast.LENGTH_SHORT).show();
                        break;
                    case Activity.RESULT_CANCELED:
                        Toast.makeText(SendSMSActivity.this,
                                "SMS not delivered", Toast.LENGTH_SHORT)
                                .show();
                        break;
                    }
                }
            }, new IntentFilter(DELIVERED));

            SmsManager sms = SmsManager.getDefault();
            sms.sendTextMessage(phoneNumber, null, message, sentPI,
                    deliveredPI);

        }
    });
}

}

0 个答案:

没有答案