I am trying to send a very long SMS message using SmsManager but when it hits that line it either crashes or throws a general error.
Here is my code: private void execute(String phone) { PendingIntent sent = PendingIntent.getBroadcast(this, 0, new Intent("SMS_SENT"), 0); registerReceiver(new BroadcastReceiver(){ @Override public void onReceive(Context arg0, Intent arg1) { switch (getResultCode()) { case Activity.RESULT_OK: Toast.makeText(getBaseContext(), "SMS sent", Toast.LENGTH_SHORT).show(); break; case SmsManager.RESULT_ERROR_GENERIC_FAILURE: Toast.makeText(getBaseContext(), "Generic failure", Toast.LENGTH_SHORT).show(); break; case SmsManager.RESULT_ERROR_NO_SERVICE: Toast.makeText(getBaseContext(), "No service", Toast.LENGTH_SHORT).show(); break; case SmsManager.RESULT_ERROR_NULL_PDU: Toast.makeText(getBaseContext(), "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("SMS_SENT")); SmsManager sms = SmsManager.getDefault(); sms.sendTextMessage(phone, null, e_msg.getText().toString(), sent, null); send.setEnabled(false); } I am attaching the logcat logs. -- -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
04-03 17:07:25.324: E/AndroidRuntime(492): FATAL EXCEPTION: main 04-03 17:07:25.324: E/AndroidRuntime(492): java.lang.NullPointerException 04-03 17:07:25.324: E/AndroidRuntime(492): at android.os.Parcel.readException(Parcel.java:1328) 04-03 17:07:25.324: E/AndroidRuntime(492): at android.os.Parcel.readException(Parcel.java:1276) 04-03 17:07:25.324: E/AndroidRuntime(492): at com.android.internal.telephony.ISms$Stub$Proxy.sendText(ISms.java:369) 04-03 17:07:25.324: E/AndroidRuntime(492): at android.telephony.SmsManager.sendTextMessage(SmsManager.java:87) 04-03 17:07:25.324: E/AndroidRuntime(492): at com.TWP.Project.TDC.Main.execute(Main.java:92) 04-03 17:07:25.324: E/AndroidRuntime(492): at com.TWP.Project.TDC.Main.access$2(Main.java:60) 04-03 17:07:25.324: E/AndroidRuntime(492): at com.TWP.Project.TDC.Main$3.onClick(Main.java:54) 04-03 17:07:25.324: E/AndroidRuntime(492): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:159) 04-03 17:07:25.324: E/AndroidRuntime(492): at android.os.Handler.dispatchMessage(Handler.java:99) 04-03 17:07:25.324: E/AndroidRuntime(492): at android.os.Looper.loop(Looper.java:123) 04-03 17:07:25.324: E/AndroidRuntime(492): at android.app.ActivityThread.main(ActivityThread.java:3683) 04-03 17:07:25.324: E/AndroidRuntime(492): at java.lang.reflect.Method.invokeNative(Native Method) 04-03 17:07:25.324: E/AndroidRuntime(492): at java.lang.reflect.Method.invoke(Method.java:507) 04-03 17:07:25.324: E/AndroidRuntime(492): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 04-03 17:07:25.324: E/AndroidRuntime(492): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 04-03 17:07:25.324: E/AndroidRuntime(492): at dalvik.system.NativeStart.main(Native Method) 04-03 17:07:52.884: E/AndroidRuntime(505): FATAL EXCEPTION: main 04-03 17:07:52.884: E/AndroidRuntime(505): java.lang.NullPointerException 04-03 17:07:52.884: E/AndroidRuntime(505): at android.os.Parcel.readException(Parcel.java:1328) 04-03 17:07:52.884: E/AndroidRuntime(505): at android.os.Parcel.readException(Parcel.java:1276) 04-03 17:07:52.884: E/AndroidRuntime(505): at com.android.internal.telephony.ISms$Stub$Proxy.sendText(ISms.java:369) 04-03 17:07:52.884: E/AndroidRuntime(505): at android.telephony.SmsManager.sendTextMessage(SmsManager.java:87) 04-03 17:07:52.884: E/AndroidRuntime(505): at com.TWP.Project.TDC.Main.execute(Main.java:92) 04-03 17:07:52.884: E/AndroidRuntime(505): at com.TWP.Project.TDC.Main.access$2(Main.java:60) 04-03 17:07:52.884: E/AndroidRuntime(505): at com.TWP.Project.TDC.Main$3.onClick(Main.java:54) 04-03 17:07:52.884: E/AndroidRuntime(505): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:159) 04-03 17:07:52.884: E/AndroidRuntime(505): at android.os.Handler.dispatchMessage(Handler.java:99) 04-03 17:07:52.884: E/AndroidRuntime(505): at android.os.Looper.loop(Looper.java:123) 04-03 17:07:52.884: E/AndroidRuntime(505): at android.app.ActivityThread.main(ActivityThread.java:3683) 04-03 17:07:52.884: E/AndroidRuntime(505): at java.lang.reflect.Method.invokeNative(Native Method) 04-03 17:07:52.884: E/AndroidRuntime(505): at java.lang.reflect.Method.invoke(Method.java:507) 04-03 17:07:52.884: E/AndroidRuntime(505): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 04-03 17:07:52.884: E/AndroidRuntime(505): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 04-03 17:07:52.884: E/AndroidRuntime(505): at dalvik.system.NativeStart.main(Native Method) 04-03 17:27:05.874: E/AndroidRuntime(515): FATAL EXCEPTION: main 04-03 17:27:05.874: E/AndroidRuntime(515): java.lang.NullPointerException 04-03 17:27:05.874: E/AndroidRuntime(515): at android.os.Parcel.readException(Parcel.java:1328) 04-03 17:27:05.874: E/AndroidRuntime(515): at android.os.Parcel.readException(Parcel.java:1276) 04-03 17:27:05.874: E/AndroidRuntime(515): at com.android.internal.telephony.ISms$Stub$Proxy.sendText(ISms.java:369) 04-03 17:27:05.874: E/AndroidRuntime(515): at android.telephony.SmsManager.sendTextMessage(SmsManager.java:87) 04-03 17:27:05.874: E/AndroidRuntime(515): at com.TWP.Project.TDC.Main.execute(Main.java:92) 04-03 17:27:05.874: E/AndroidRuntime(515): at com.TWP.Project.TDC.Main.access$2(Main.java:60) 04-03 17:27:05.874: E/AndroidRuntime(515): at com.TWP.Project.TDC.Main$3.onClick(Main.java:54) 04-03 17:27:05.874: E/AndroidRuntime(515): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:159) 04-03 17:27:05.874: E/AndroidRuntime(515): at android.os.Handler.dispatchMessage(Handler.java:99) 04-03 17:27:05.874: E/AndroidRuntime(515): at android.os.Looper.loop(Looper.java:123) 04-03 17:27:05.874: E/AndroidRuntime(515): at android.app.ActivityThread.main(ActivityThread.java:3683) 04-03 17:27:05.874: E/AndroidRuntime(515): at java.lang.reflect.Method.invokeNative(Native Method) 04-03 17:27:05.874: E/AndroidRuntime(515): at java.lang.reflect.Method.invoke(Method.java:507) 04-03 17:27:05.874: E/AndroidRuntime(515): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 04-03 17:27:05.874: E/AndroidRuntime(515): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 04-03 17:27:05.874: E/AndroidRuntime(515): at dalvik.system.NativeStart.main(Native Method) 04-03 17:39:19.154: E/AndroidRuntime(560): FATAL EXCEPTION: main 04-03 17:39:19.154: E/AndroidRuntime(560): java.lang.NullPointerException 04-03 17:39:19.154: E/AndroidRuntime(560): at android.os.Parcel.readException(Parcel.java:1328) 04-03 17:39:19.154: E/AndroidRuntime(560): at android.os.Parcel.readException(Parcel.java:1276) 04-03 17:39:19.154: E/AndroidRuntime(560): at com.android.internal.telephony.ISms$Stub$Proxy.sendText(ISms.java:369) 04-03 17:39:19.154: E/AndroidRuntime(560): at android.telephony.SmsManager.sendTextMessage(SmsManager.java:87) 04-03 17:39:19.154: E/AndroidRuntime(560): at com.TWP.Project.TDC.Main.execute(Main.java:92) 04-03 17:39:19.154: E/AndroidRuntime(560): at com.TWP.Project.TDC.Main.access$2(Main.java:60) 04-03 17:39:19.154: E/AndroidRuntime(560): at com.TWP.Project.TDC.Main$3.onClick(Main.java:54) 04-03 17:39:19.154: E/AndroidRuntime(560): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:159) 04-03 17:39:19.154: E/AndroidRuntime(560): at android.os.Handler.dispatchMessage(Handler.java:99) 04-03 17:39:19.154: E/AndroidRuntime(560): at android.os.Looper.loop(Looper.java:123) 04-03 17:39:19.154: E/AndroidRuntime(560): at android.app.ActivityThread.main(ActivityThread.java:3683) 04-03 17:39:19.154: E/AndroidRuntime(560): at java.lang.reflect.Method.invokeNative(Native Method) 04-03 17:39:19.154: E/AndroidRuntime(560): at java.lang.reflect.Method.invoke(Method.java:507) 04-03 17:39:19.154: E/AndroidRuntime(560): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 04-03 17:39:19.154: E/AndroidRuntime(560): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 04-03 17:39:19.154: E/AndroidRuntime(560): at dalvik.system.NativeStart.main(Native Method)