Java 在Android设备上循环浏览图像库
有没有办法在安卓设备上循环浏览默认的图像库? 在我的应用程序中,我已通过以下代码将所选图片从默认图库传递到imageView:Java 在Android设备上循环浏览图像库,java,android,gallery,Java,Android,Gallery,有没有办法在安卓设备上循环浏览默认的图像库? 在我的应用程序中,我已通过以下代码将所选图片从默认图库传递到imageView: public void onImageGalleryClicked(View v){ //Invoke image gallery using implicit intent Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); //Where is the image galle
public void onImageGalleryClicked(View v){
//Invoke image gallery using implicit intent
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
//Where is the image gallery stored
File pictureDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
//Get path of the image gallery as string
CurrentPicturePath = pictureDirectory.getPath();
//Get the URI-representation of the image directory path
Uri data = Uri.parse(CurrentPicturePath);
//Set the data and type to get all the images
photoPickerIntent.setDataAndType(data, "image/*");
//Invoke activity and wait for result
startActivityForResult(photoPickerIntent, IMAGE_GALLERY_REQUEST);
}
以及通过以下方式在viewcontroller中显示图片:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(resultCode == RESULT_OK){
if(requestCode == IMAGE_GALLERY_REQUEST){
//Address of the image on SD-card
Uri imageUri = data.getData();
//Declare a stream to read the image from SD-card
InputStream inputStream;
try {
inputStream = getContentResolver().openInputStream(imageUri);
//Get a bitmap
Bitmap image = BitmapFactory.decodeStream(inputStream);
imgPicture.setImageBitmap(image);
} catch (FileNotFoundException e) {
e.printStackTrace();
Toast.makeText(this, "Unable to open image!", Toast.LENGTH_LONG).show();
}
}
}
}
现在我想在我的应用程序中有一个按钮,可以在默认图库中查找下一张图片。
我想通过一种方式在图库中循环查找我的当前图片(按路径/名称!?),以便能够选择下一张(或上一张)有数十亿台Android设备,分布在数千种设备型号中。这些应用程序将有数百种不同的“默认图像库”应用程序,这些应用程序通常由设备制造商编写。用户不必使用这些应用程序中的任何一个来满足您的
ACTION\u PICK
请求
不要求操作\u PICK
实现为您提供“下一步”或“前进”信息。可能重复的