in my app i have an option to show the images in sd card, from that the user can select one image and it will be loaded in the the image view of my next activity.
I have tested the app in two of my devices such as Samsung Ace and Samsung Galaxy S3.
In Samsung Ace of 2.3 version, i am able to select the image and from onActivity result the next Activity is called and the image gets loaded in Imageview, here i am able to do this for n number of times,(other option i use is capture via camera and load in next activity, here too the process is good)
When i tried the same process in Samsung Galaxy S3, of version 4.2, for the first time i am able to select or capture via camera and load it in imageview. When i tried for the second time the app gets crashed, saying that
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): !@Dumpstate > 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
I tried using following 2 methods to load the captured image or selected image in ImageView Method 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);
Method 2
Bitmap bitmap = BitmapFactory.decodeFile(Appconstants.f);
ImageView uplaod_image.setImageBitmap(bitmap);
But everytime the app crashes saying the above error, how to resolve this....