Why choose a picture from the gallery by >>Intent<< > can't show in some devices. I'm Thai ,Sorry for my language ...Thank U
public void click(View v){
intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
startActivityForResult(Intent.createChooser(intent, "select??"), 1);
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK&&requestCode == 1) {
Uri uri = Uri.parse(get_Path(data.getData()));
//--I use This >>uri<< for setImage ....But cant't show in some devices.?
}
}
public String get_Path(Uri uri) {
String path = ""; ///////////////
Cursor cursor = getContentResolver().query(uri, null, null, null, null);
if (cursor == null) {
path = uri.getPath();
} else {
cursor.moveToFirst();
int num = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA);
path = cursor.getString(num);
cursor.close();
}
return path;
}
Beginning in Android 6.0 or >7 (API level 23), users grant permissions to apps while the app is running, not when they install the app. read about this
and follow this link of my ans my question how to ask runtime permssion
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.