I just migrated my code from sdk 22 to sdk 23, and on the test phone (moto g3) I had no problems, but it turns out that there are devices that have problems (Samsung Galaxy J2)... Before when I used compileSdkVersion = 22, both phones were working but now that i use 23 the samsung drops...
At the code level I try to obtain a getPath of a Bitmap.
First I get the getUri of the bitmap, and then use it to get the getPath, as follows:
Bitmap bm = ((BitmapDrawable) mImagenView.getDrawable()).getBitmap();
Uri tempUri = getImageUri(getApplicationContext(), bm); //aca se caé
...
public Uri getImageUri(Context inContext, Bitmap inImage) {
if(verificarPermisoAlmacenamiento()) {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
inImage.compress(Bitmap.CompressFormat.PNG, 100, bytes);
String path = MediaStore.Images.Media.insertImage(inContext.getContentResolver(), inImage, "Title", null); //especificamente aqui
return Uri.parse(path);
}
}
here path is null... on the samsung.
Is it due to some change in the C:.....\Android\sdk\sources\android-23\android\provider library?
ALL help is welcome...
Your problem is getting the path of the image:
If we review the documentation we find that:
First make sure you have the permission:
Remember that if your device uses Android 6.0 permissions should be required , this can also be a cause for which you get a value
null
.You can add this code segment to require permissions on android 6.0 devices
Fixed!
Since I couldn't use GetImageUri() I was searching and it turns out that the Uri is obtained from the Intent
correct answer here