Thanks On Fri, 16 Apr 2021 at 04:50, Shai Almog <[email protected]> wrote:
> Hi, > I've asked Steve to look into this issue and raised its priority to > critical. > > On Friday, April 16, 2021 at 12:10:34 AM UTC+3 [email protected] wrote: > >> Darn it >> >> Got this message today. This unresolved, high-priority, 8-months-old >> issue is finally coming to bite in the ass >> https://github.com/codenameone/CodenameOne/issues/3204 >> We won't be able to update or publish any existing app that uses the >> Gallery on Android unless this is resolved. The workaround proposed by Shai >> in the issue is going to be shut down on the 5th of May >> >> We've detected that your app contains the 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: >> >> - Update your app to use more privacy-friendly best practices, such >> as the storage access framework or Media Store API >> - Update your app to declare the All files access ( >> MANAGE_EXTERNAL_STORAGE) permission in the manifest file, and >> complete the All files access permission declaration in Play Console from >> 5 >> May >> - Remove the All files access permission from your app entirely >> >> For 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/codenameone-discussions/1179bb13-e115-4969-b3f2-400787765742n%40googlegroups.com > <https://groups.google.com/d/msgid/codenameone-discussions/1179bb13-e115-4969-b3f2-400787765742n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/CAG90yJ13sid90P080FTS3xS83bGqinEhEE1oLEGNPkr5jJ6Lzw%40mail.gmail.com.
