android - Unable to resume activity, App crash after using camera -


who can me review bug, in activity startactivityforresult (used camera take image). after taken photo, activity can't resume. :(

java.lang.runtimeexception: unable resume activity {com.example/com.example.view.main.personactivity}: java.lang.runtimeexception: failure delivering result resultinfo{who=null, request=998, result=-1, data=null} activity {com.example/com.example.view.main.personactivity}: java.lang.nullpointerexception  --------- stack trace ---------      android.app.activitythread.performresumeactivity(activitythread.java:2458)     android.app.activitythread.handleresumeactivity(activitythread.java:2486)     android.app.activitythread.handlelaunchactivity(activitythread.java:2000)     android.app.activitythread.access$600(activitythread.java:128)     android.app.activitythread$h.handlemessage(activitythread.java:1161)     android.os.handler.dispatchmessage(handler.java:99)     android.os.looper.loop(looper.java:137)     android.app.activitythread.main(activitythread.java:4514)     java.lang.reflect.method.invokenative(native method)     java.lang.reflect.method.invoke(method.java:511)     com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:790)     com.android.internal.os.zygoteinit.main(zygoteinit.java:557)     dalvik.system.nativestart.main(native method) -------------------------------  --------- cause ---------  java.lang.runtimeexception: failure delivering result resultinfo{who=null, request=998, result=-1, data=null} activity {com.example/com.example.view.main.personactivity}: java.lang.nullpointerexception      android.app.activitythread.deliverresults(activitythread.java:2994)     android.app.activitythread.performresumeactivity(activitythread.java:2445)     android.app.activitythread.handleresumeactivity(activitythread.java:2486)     android.app.activitythread.handlelaunchactivity(activitythread.java:2000)     android.app.activitythread.access$600(activitythread.java:128)     android.app.activitythread$h.handlemessage(activitythread.java:1161)     android.os.handler.dispatchmessage(handler.java:99)     android.os.looper.loop(looper.java:137)     android.app.activitythread.main(activitythread.java:4514)     java.lang.reflect.method.invokenative(native method)     java.lang.reflect.method.invoke(method.java:511)     com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:790)     com.android.internal.os.zygoteinit.main(zygoteinit.java:557)     dalvik.system.nativestart.main(native method) ------------------------------- 

in java-code, @ onactivityresult

@override protected void onactivityresult(int requestcode, int resultcode, intent data) {     string filepath = "";     switch (requestcode) {     case myactivity.rq_sale_take_photo:         {             if (resultcode == result_ok) {                 if (data != null && data.getextras() != null && data.getaction() != null) {                     bitmap tempbitmap = null;                     tempbitmap = (bitmap) data.getextras().get("data");                     //.....                 }             } else {                 //do here             }         }         break;     } } 

code call camera :

public static file takephoto(activity sender, int requestcode) {     system.gc();     final intent intent = new intent(mediastore.action_image_capture);      string filename = constants.temp_img + "_" + dateutils.getcurrentdatetimewithformat(null) + ".jpg";     file retfile = new file(externalstorage.gettakenphotopath(sender), filename);     if (!retfile.exists())         try {             retfile.createnewfile();         } catch (ioexception e) {             // todo auto-generated catch block             e.printstacktrace();         }     intent.putextra(mediastore.extra_output, uri.fromfile(retfile));     sender.startactivityforresult(intent, requestcode);     return retfile; } 

can me explain above error, , how fix error.

seems return intent "data" null

make sure use startactivityforresult , default camera application.

the default android camera application returns non-null intent when passing thumbnail in returned intent. if pass extra_output url write to, return null intent , pictures in url passed in.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -