好久不做安卓了,把原来工程的七牛上传图片的代码粘贴过来,运行竟然出错了
提示 open failed: EACCES (Permission denied)
其实这是Android6.0以后运行时权限的问题
解决办法:
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { //申请WRITE_EXTERNAL_STORAGE权限 ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, WRITE_EXTERNAL_STORAGE_REQUEST_CODE); }
然后咱根据回调进行操作