Android SmsReceiver crash my app if it's running in background when receive msn -
if inside app, can check if have received sms play video. if press home button , app running in background, if sms received app crash.
thanks guys.
**my code: inside ** public class smsreceiver extends broadcastreceiver {
... if (run if corrected sms received ){ //pause video in playvideoactivity //playvideoactivity.mvideoview.pause(); /** go dialog box 2 confirmation **/ playvideoactivity.dialogtextcomfirmrun(); } ...
the error sms
06-27 11:05:30.611: d/androidruntime(707): shutting down vm 06-27 11:05:30.631: w/dalvikvm(707): threadid=1: thread exiting uncaught exception (group=0x40015560) 06-27 11:05:30.671: e/androidruntime(707): fatal exception: main 06-27 11:05:30.671: e/androidruntime(707): java.lang.runtimeexception: unable start receiver com.example.brazilapps.smsreceiver: java.lang.nullpointerexception 06-27 11:05:30.671: e/androidruntime(707): @ android.app.activitythread.handlereceiver(activitythread.java:1805) 06-27 11:05:30.671: e/androidruntime(707): @ android.app.activitythread.access$2400(activitythread.java:117) 06-27 11:05:30.671: e/androidruntime(707): @ android.app.activitythread$h.handlemessage(activitythread.java:981) 06-27 11:05:30.671: e/androidruntime(707): @ android.os.handler.dispatchmessage(handler.java:99) 06-27 11:05:30.671: e/androidruntime(707): @ android.os.looper.loop(looper.java:123) 06-27 11:05:30.671: e/androidruntime(707): @ android.app.activitythread.main(activitythread.java:3683) 06-27 11:05:30.671: e/androidruntime(707): @ java.lang.reflect.method.invokenative(native method) 06-27 11:05:30.671: e/androidruntime(707): @ java.lang.reflect.method.invoke(method.java:507) 06-27 11:05:30.671: e/androidruntime(707): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:839) 06-27 11:05:30.671: e/androidruntime(707): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:597) 06-27 11:05:30.671: e/androidruntime(707): @ dalvik.system.nativestart.main(native method) 06-27 11:05:30.671: e/androidruntime(707): caused by: java.lang.nullpointerexception 06-27 11:05:30.671: e/androidruntime(707): @ android.widget.toast.<init>(toast.java:89) 06-27 11:05:30.671: e/androidruntime(707): @ android.widget.toast.maketext(toast.java:231) 06-27 11:05:30.671: e/androidruntime(707): @ com.example.brazilapps.playvideoactivity.dialogtextcomfirmrun(playvideoactivity.java:302) 06-27 11:05:30.671: e/androidruntime(707): @ com.example.brazilapps.smsreceiver.onreceive(smsreceiver.java:81) 06-27 11:05:30.671: e/androidruntime(707): @ android.app.activitythread.handlereceiver(activitythread.java:1794) 06-27 11:05:30.671: e/androidruntime(707): ... 10 more
someone advice me to : tip: in ur receiver class file open dialog activity - don't know how open dialog if app running in background.
any great. again
you can start activity broadcastreceiver using code:
puboic void onreceive(context context, intent intent){ ... if (run if corrected sms received ){ // context can context object in argument of onreceive method intent = new intent(context, playvideoactivity.class); i.setflags(intent.flag_activity_new_task); // use i.puextra() pass data context.startactivity(i); } }
after starting activity can open dialog activity or needs user interface.
and logcat showing null pointer exception. should add code playvideoactivity.dialogtextcomfirmrun() method find out wrong current approach.
Comments
Post a Comment