在我的應用程序中的錯誤我有一個選項,以顯示在SD卡中的圖像,用戶可以選擇一個圖像,它會被加載我的下一個活動的圖像視圖。android從sd卡載入圖像到imageview創建內存不足三星SIII
我已經在我的兩個設備(如三星Ace和三星Galaxy S3)中測試了該應用程序。
在2.3版本的三星Ace中,我可以選擇圖像並從onActivity結果中調用下一個Activity,圖像在Imageview中加載,在這裏我可以做到n次,(其他我使用的選項是通過相機捕獲和加載在下一個活動,這裏也是這個過程是好的)
當我在第一次嘗試在三星Galaxy S3,版本4.2的相同過程,我可以選擇或捕獲通過相機並在imageview中加載它。當我試圖在第二次應用程序被墜毀,說
E/dalvikvm-heap(7058): Out of memory on a 31961104-byte allocation.
E/AndroidRuntime(7058): FATAL EXCEPTION: main
E/AndroidRuntime(7058): java.lang.OutOfMemoryError
E/AndroidRuntime(7058): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
E/AndroidRuntime(7058): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:587)
E/AndroidRuntime(7058): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:389)
E/AndroidRuntime(7058): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:418)
E/AndroidRuntime(7058): at com.tribal.pages.app.UploadPhoto$ShowCapturedImage.onPostExecute(UploadPhoto.java:442)
E/AndroidRuntime(7058): at com.tribal.pages.app.UploadPhoto$ShowCapturedImage.onPostExecute(UploadPhoto.java:1)
E/AndroidRuntime(7058): at android.os.AsyncTask.finish(AsyncTask.java:602)
E/AndroidRuntime(7058): at android.os.AsyncTask.access$600(AsyncTask.java:156)
E/AndroidRuntime(7058): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:615)
E/AndroidRuntime(7058): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(7058): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(7058): at android.app.ActivityThread.main(ActivityThread.java:4517)
E/AndroidRuntime(7058): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(7058): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(7058): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
E/AndroidRuntime(7058): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
E/AndroidRuntime(7058): at dalvik.system.NativeStart.main(Native Method)
E/android.os.Debug(2098): [email protected] > dumpstate -k -t -n -z -d -o /data/log/dumpstate_app_error
E/widget (2468): [MSC_HERO_Accu]>>> SM:399 [0:0] IR : false, IPR : false
E/Launcher(2468): Error finding setting, default accessibility to not found: accessibility_enabled
E/widget (2468): [MSC_HERO_Accu]>>> SM:399 [0:0] IR : false, IPR : false
我使用以下2種方法來加載在ImageView的 方法所捕獲的圖像或選擇的圖像試圖1
Bitmap bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(Appconstants._uri));
bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
ImageView uplaod_image.setImageBitmap(bitmap);
方法2
Bitmap bitmap = BitmapFactory.decodeFile(Appconstants.f);
ImageView uplaod_image.setImageBitmap(bitmap);
但每次應用程序崩潰說上面的錯誤,如何解決這個....
那張圖片有多大? – xfx
你的意思是大小 - 所拍攝的圖像大約爲1.2MB到1.7MB ..... –