java - Application crashing when images with particular resolutions are selected -
i have method converts image round shape , sets in imageview. method works in of cases, misbehaves when images resolutions selected.
the method:
public void decodeimagefile(string imagepath, matrix m){ // need dp px algorith herer bitmap bitmap = decodesamplebitmapfromfile(imagepath, 1024, 1024); //bitmap = bitmap.createscaledbitmap(bitmap, 540, 960, true); int w = bitmap.getwidth(); int h = bitmap.getheight(); log.e("height", ""+h); log.e("width", ""+w); //to prevent crashing app not legal resolution // if (h == 1920 && w == 2160) { // bitmap = bitmap.createscaledbitmap(bitmap, 540, 960, true); // } // logic check whether resulting image has height or // width greater 0 if (bitmap.getwidth() > 0 && bitmap.getheight() > 0) { bitmap = bitmap.createbitmap(bitmap, 0, 0, bitmap.getwidth(), bitmap.getheight(), m, true); bitmap = imagecontroller.transfersquare(bitmap); bytearrayoutputstream baos = new bytearrayoutputstream(); bitmap.compress(bitmap.compressformat.jpeg, 100, baos); base64.encodetostring(baos.tobytearray(), base64.default); bytearray = baos.tobytearray(); bitmap = imagecontroller.resizetohighresolutioncircle(bitmap); choosephotobtn.setbackgroundresource(r.drawable.add_detail_photo_opaq_xhdpi); yourphoto.setimagebitmap(bitmap.createscaledbitmap(bitmap, yourphoto.getwidth(), yourphoto.getheight(), false)); } }
i have seen crashes 1080x1920 , 1920x2160 resolutions. the logcat 1080x1920 resolution:
12-02 13:26:57.255: d/dalvikvm(28494): gc_for_alloc freed 14357k, 28% free 37780k/52472k, paused 17ms, total 17ms 12-02 13:26:57.335: e/height(28494): 1080 12-02 13:26:57.335: e/width(28494): 1920 12-02 13:26:57.350: d/dalvikvm(28494): gc_for_alloc freed 93k, 21% free 41738k/52472k, paused 12ms, total 12ms 12-02 13:26:57.355: i/dalvikvm-heap(28494): grow heap (frag case) 46.646mb 4147216-byte allocation 12-02 13:26:57.365: d/dalvikvm(28494): gc_for_alloc freed <1k, 19% free 45788k/56524k, paused 11ms, total 11ms 12-02 13:26:57.610: d/dalvikvm(28494): gc_for_alloc freed 9108k, 27% free 42971k/58508k, paused 14ms, total 14ms 12-02 13:26:57.635: d/dalvikvm(28494): gc_for_alloc freed 5156k, 22% free 43217k/54748k, paused 15ms, total 15ms 12-02 13:26:57.645: i/dalvikvm-heap(28494): grow heap (frag case) 48.585mb 4665616-byte allocation 12-02 13:26:57.665: d/dalvikvm(28494): gc_for_alloc freed 0k, 20% free 47773k/59308k, paused 17ms, total 17ms 12-02 13:27:03.610: w/dalvikvm(29085): threadid=12: thread exiting uncaught exception (group=0x41939c08) 12-02 13:27:03.610: e/androidruntime(29085): fatal exception: parse.initialize disk check & starting command cache 12-02 13:27:03.610: e/androidruntime(29085): process: com.navitas.studystory, pid: 29085 12-02 13:27:03.610: e/androidruntime(29085): java.lang.securityexception: unable find app caller android.app.applicationthreadproxy@43839f28 (pid=29085) when registering receiver android.content.iintentreceiver$stub$proxy@42c70b60 12-02 13:27:03.610: e/androidruntime(29085): @ android.os.parcel.readexception(parcel.java:1472) 12-02 13:27:03.610: e/androidruntime(29085): @ android.os.parcel.readexception(parcel.java:1426) 12-02 13:27:03.610: e/androidruntime(29085): @ android.app.activitymanagerproxy.registerreceiver(activitymanagernative.java:2551) 12-02 13:27:03.610: e/androidruntime(29085): @ android.app.contextimpl.registerreceiverinternal(contextimpl.java:1821) 12-02 13:27:03.610: e/androidruntime(29085): @ android.app.contextimpl.registerreceiver(contextimpl.java:1789) 12-02 13:27:03.610: e/androidruntime(29085): @ android.app.contextimpl.registerreceiver(contextimpl.java:1783) 12-02 13:27:03.610: e/androidruntime(29085): @ android.content.contextwrapper.registerreceiver(contextwrapper.java:479) 12-02 13:27:03.610: e/androidruntime(29085): @ com.parse.connectivitynotifier.trytoregisterfornetworkstatusnotifications(connectivitynotifier.java:55) 12-02 13:27:03.610: e/androidruntime(29085): @ com.parse.connectivitynotifier.addlistener(connectivitynotifier.java:34) 12-02 13:27:03.610: e/androidruntime(29085): @ com.parse.parsecommandcache.<init>(parsecommandcache.java:101) 12-02 13:27:03.610: e/androidruntime(29085): @ com.parse.parse.geteventuallyqueue(parse.java:527) 12-02 13:27:03.610: e/androidruntime(29085): @ com.parse.parse$1.run(parse.java:126) 12-02 13:27:03.680: w/applicationpackagemanager(29098): getcscpackageitemtext() 12-02 13:27:03.780: d/dalvikvm(29098): gc_for_alloc freed 206k, 12% free 17072k/19260k, paused 18ms, total 19ms 12-02 13:27:03.795: i/dalvikvm-heap(29098): grow heap (frag case) 25.620mb 7356976-byte allocation 12-02 13:27:03.815: d/dalvikvm(29098): gc_for_alloc freed 0k, 9% free 24257k/26448k, paused 17ms, total 17ms 12-02 13:27:03.845: e/lifecycle(29098): oncreate() event 12-02 13:27:03.845: e/lifecycle(29098): onstart() event 12-02 13:27:03.850: e/lifecycle(29098): onresume() event 12-02 13:27:03.940: d/openglrenderer(29098): enabling debug mode 0 12-02 13:27:33.950: e/lifecycle(29098): onpause() event 12-02 13:27:33.955: e/lifecycle(29098): onstop() event
please tell me going wrong? miss?
create class
public class myuncaughtexceptionhandler implements thread.uncaughtexceptionhandler { @override public void uncaughtexception(thread thread, throwable ex) { if(ex.getclass().equals(outofmemoryerror.class)) { try { android.os.debug.dumphprofdata("/sdcard/dump.hprof"); } catch (ioexception e) { e.printstacktrace(); } } ex.printstacktrace(); } }
and put following code in mainactivity
thread.currentthread().setdefaultuncaughtexceptionhandler(new myuncaughtexceptionhandler());
Comments
Post a Comment