[英]How to get photo from stock galleries other than google Photos in Android Lollipop and higher?
我正在使用以下代碼從圖庫中選擇圖像。
//Override For uploading the image.
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE);
}
//for showing the selected image.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode==RESULT_LOAD_IMAGE && resultCode==RESULT_OK && data!=null)
{
Uri selectedimage=data.getData();
imagetoupload.setImageURI(selectedimage);
}
}
它僅從Google相冊應用程序中選擇圖片。 我想從“圖庫”應用程序中選擇圖像,該應用程序作為手機中的圖庫提供。 當我從我的Gallery應用程序中選擇時,未選擇圖像,而在顯示選擇的圖像時,未顯示圖像。
使用ACTION_GET_CONTENT
或ACTION_OPEN_DOCUMENT
,具體取決於您所運行的Android版本(如本文檔所述) 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.