android - What could cause file path NULL only on Galaxy S4 5.0.1? -


a file being caught camera. don't use intent, save file tempfile object. code

private static final int image_capture = 1002; //class-wide private string mcurrentphotopath; //class-wide  //... file photofile = createimagefile(); uri uri = uri.fromfile(photofile); intent.putextra(mediastore.extra_output, uri); startactivityforresult(intent, image_capture);  //... private file createimagefile() throws ioexception {         imagename = mcodecontent + "_" + integer.tostring(randomnumber) + ".png";         file storagedir = environment.getexternalstoragepublicdirectory(environment.directory_pictures);         file image = file.createtempfile(imagename, ".png", storagedir);         mcurrentphotopath = image.getabsolutefile().getpath();         mimagenamelist.add(imagename);         return image; } 

but moment, variable mcurrentphotopath not null.

however, after user takes image, variable mcurrentphotopath becomes null in onactivityresult creates crash

case image_capture:      try {           uri uri = uri.fromfile(new file(mcurrentphotopath)); //<---crash!!!           handlecameraimage(uri);           } catch (exception e) {           toast.maketext(this, "error (image_capture)" + "\nmcurrentphotopath=" +                                 mcurrentphotopath + "\n log: " + e.getmessage(), toast.length_long).show();          }          break; 

the image path on s4 looks /storage/emulated/0/pictures/imagename.png.

what causing or deleting mcurrentphotopath? , on s4, not on other devices.

ps. tried saving value shared preferences, @ point deleted well.

in samsung phones orientation change when camera app opened. cause our activity restart.

so add configchanges activity in manifest file

android:configchanges="orientation" 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -