目前,已知的解决方法是在应用程序代码中添加以下行,即:在应用程序的MainActivity的onCreate()方法中添加如下代码:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !Environment.isExternalStorageManager()) { Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION); Uri uri = Uri.fromParts("package", getPackageName(), null); intent.setData(uri); startActivity(intent); }
上述代码将要求您的应用程序获得Android 11中的系统存储访问权限,从而避免应用程序冻结的问题。将代码添加到应用程序代码中,并重新构建您的应用程序,应用程序应该无法正常工作。