public class MainActivity extends AppCompatActivity implements ActivityCompat.OnRequestPermissionsResultCallback{ private static final int REQUEST_WRITE_PERMISSION = 786; @OverrIDe public voID onRequestPermissionsResult(int requestCode,String[] permissions,int[] grantResults) { if (requestCode == REQUEST_WRITE_PERMISSION && grantResults[0] == PackageManager.PERMISSION_GRANTED) { openfilePicker(); } } @OverrIDe protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_main); requestPermission(); } private voID requestPermission() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestPermissions(new String[]{androID.Manifest.permission.WRITE_EXTERNAL_STORAGE},REQUEST_WRITE_PERMISSION); } else { openfilePicker(); } }}总结
以上是内存溢出为你收集整理的android – 棉花糖的存储和图库使用的读写权限全部内容,希望文章能够帮你解决android – 棉花糖的存储和图库使用的读写权限所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)