Open Goncharuk-Nikita opened 5 years ago
Minimum API Level set to 24 Traget API Level set to 28
I your documentation write that the target API should be 27, can this cause issue?
Hi, I think I solved this issue by adding the permission request before saving: // Manage Android Permissions
if (!Permission.HasUserAuthorizedPermission(Permission.ExternalStorageWrite))
{
Permission.RequestUserPermission(Permission.ExternalStorageWrite);
}
NativeToolkit.SaveImage(m_BGTexture, "Save", "jpg" );
However, the image is not copied into the gallery, (/gallery/ or pictures), but stays in Android/data/myApp/files/Save.jpg
I am using Unity 2019.1 and Android minimum target 27. Even the example project has the same issue.
Moreover, it cannot overwrite this image. Is this normal ? Please help !
Thank you for your answer.
Moreover, it cannot overwrite this image. Is this normal ?
For me, i save the each new screenshot with the new file name and do not overwrite there. But I also tested your version: the image is successfully overwritten, but the preview image in the gallery is not updated, then when you click on this image, you see a new one.
private string GetPhotoName()
{
return $"{_photoSuffix}_{DateTime.Now:dd-MM-yyyy-HH-mm-ss}";
}
However, the image is not copied into the gallery, (/gallery/ or pictures), but stays in Android/data/myApp/files/Save.jpg
This is not important for my task, but I also wanted to know if it is possible?
Thanks for your answer, I also have detected this gallery app update issue.
On iOS this function works perfectly, gallery/update, ect., but not on Android. I guess the update issue has nothing to do with NativeToolkit, however the copy into /Gallery/, IMHO, should be part of the function. Or a copyToDir function.
Thanks for the reply.
When i call
NativeToolkit.SaveImage
I get the exception:AndroidPlayer(ADB@127.0.0.1:34999) AndroidJavaException: java.lang.SecurityException: Permission Denial: writing com.android.providers.media.MediaProvider uri content://media/external/images/media from pid=30377, uid=10392 requires android.permission.WRITE_EXTERNAL_STORAGE, or grantUriPermission() java.lang.SecurityException: Permission Denial: writing com.android.providers.media.MediaProvider uri content://media/external/images/media from pid=30377, uid=10392 requires android.permission.WRITE_EXTERNAL_STORAGE, or grantUriPermission()
My manifest permissions:
External (SD Card checked)
Unity 2019.1.3f1