requestLegacyExternalStorage flag in the manifest file of one or more of your app bundles or APKs.Developers with apps on devices running Android 11+ must use scoped storage to give users better access control over their device storage. To release your app on Android 11 or newer after 5 May, you must either:
MANAGE_EXTERNAL_STORAGE) permission in the manifest file, and complete the All files access permission declaration in Play Console from 5 MayFor apps targeting Android 11, the requestLegacyExternalStorage flag will be ignored. You must use the All files access permission to retain broad access.
Apps requesting access to the All files access permission without a permitted use will be removed from Google Play, and you won't be able to publish updates.
I am not 100% sure of what needs fixing in CN1, but I recently had to do some native android work where I needed to read images from an intent in the most up-to-date way. The below code allowed me to get these images from an intent (the code gets images shared into an app with the latest APIs etc). Just sharing in case it helps
Intent intent = getIntent();Uri sharedFileUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);if(sharedFileUri != null)
{
FileInputStream input = null;
FileOutputStream output = null;
try
{
//first get filename
String originalFieName = getFileName(sharedFileUri);
String filePath = new File(getCacheDir(), originalFieName).getAbsolutePath();
android.os.ParcelFileDescriptor pfd = getContentResolver().openFileDescriptor(sharedFileUri, "r");
if(pfd != null)
{
FileDescriptor fd = pfd.getFileDescriptor();
input = new FileInputStream(fd);
output = new FileOutputStream(filePath);
int read;
byte[] bytes = new byte[4096];
while ((read = input.read(bytes)) != -1) {
output.write(bytes, 0, read);
}
File sharedFile = new File(filePath);
String finalPath = sharedFile.getPath();//this is the final image path to be used
}
}catch(Exception ex){}
finally{
try {
input.close();
output.close();
} catch (Exception ignored) {}
}
}
}public String getFileName(Uri uri) {
try
{
String result = null;
if (uri.getScheme().equals("content")) {
Cursor cursor = getContentResolver().query(uri, null, null, null, null);
try {
if (cursor != null && cursor.moveToFirst()) {
result = cursor.getString(cursor.getColumnIndex(android.provider.OpenableColumns.DISPLAY_NAME));
}
} finally {
cursor.close();
}
}
if (result == null) {
result = uri.getPath();
int cut = result.lastIndexOf('/');
if (cut != -1) {
result = result.substring(cut + 1);
}
}
return result;
}catch(Exception e)
{
return "temp_file";
}
}
--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/1179bb13-e115-4969-b3f2-400787765742n%40googlegroups.com.