我的项目有 3 项不同的活动。第一个活动包含所有权限请求。应用程序已授予所有权限,但仍然无法在 SD 卡上写入文件。如果我关闭应用程序并再次启动,那么我可以在 SD 卡上写入文件。无论如何,是否有多个活动的更新权限。
public class PermissionActivity extends AppCompatActivity {
public static final int REQUEST_ID_MULTIPLE_PERMISSIONS = 1;
private static int TIME_OUT = 2000;
private String TAG = "tag";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_permission);
Locale locale = new Locale("en");
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
this.getResources().updateConfiguration(config, null);
if(checkAndRequestPermissions()) {
// carry on the normal flow, as the case of permissions granted.
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// This …Run Code Online (Sandbox Code Playgroud)