Attempting to save a bitmap to the 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 an emulator and received a 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 an Android device right now, is it because of the emulator? Or another reason?
source share