QQ图片存储失败,请检查图片或者检查是否有读写权限

1.设置AndroidManifest.xml

android.permission.WRITE_EXTERNAL_STORAGE

android.permission.READ_EXTERNAL_STORAGE

2.没有sd卡,qq不能分享本地图片Activtiy里手动添加

3.如果使用 targetSdkVersion 23或23以上,需要做6.0适配,手动获取WRITE_EXTERNAL_STORAGE权限,否则QQ不能进行图片分享

private static final intREQUEST_EXTERNAL_STORAGE=1;

private staticString[]PERMISSIONS_STORAGE= {

Manifest.permission.READ_EXTERNAL_STORAGE,

Manifest.permission.WRITE_EXTERNAL_STORAGE

};

intpermission = ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);

if(permission != PackageManager.PERMISSION_GRANTED) {

// We don't have permission so prompt the user

ActivityCompat.requestPermissions(

this,

PERMISSIONS_STORAGE,

REQUEST_EXTERNAL_STORAGE

);

}

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐