Trying saving bitmap into gallery
Bitmap bitmap = Bitmap.createBitmap(surfaceView.getWidth(), surfaceView.getHeight(), Bitmap.Config.ARGB_8888);
surfaceView.draw(new Canvas(bitmap));
MediaStore.Images.Media.insertImage(getContentResolver(), bitmap, "foo" , "bar");
I ran the application on the emulator and got an UnsupportedOperationException.
07-25 22:27:48.719: E/MediaStore(1918): Failed to insert image
07-25 22:27:48.719: E/MediaStore(1918): java.lang.UnsupportedOperationException: Unknown URI: content://media/external/images/media
07-25 22:27:48.719: E/MediaStore(1918): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:168)
07-25 22:27:48.719: E/MediaStore(1918): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:136)
07-25 22:27:48.719: E/MediaStore(1918): at android.content.ContentProviderProxy.insert(ContentProviderNative.java:415)
07-25 22:27:48.719: E/MediaStore(1918): at android.content.ContentResolver.insert(ContentResolver.java:730)
07-25 22:27:48.719: E/MediaStore(1918): at android.provider.MediaStore$Images$Media.insertImage(MediaStore.java:801)
Unfortunately I don't have any android device right now, is this because of the emulator? Or another reason?
I have had similar problems when the directory DCIM/Camera didn't exist on the sdcard. Creating the directory (and having the permission) has resolved a similar problem for me.
I found that it was an emulator problem. I had not set up the emulator correctly. To fix this what I did was to open the android Virtual device manager, edit the AVD and add a SD Card size. Once I have done that I start the AVD and take a picture. After I have done that, it started working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With