I'm looking to display a specific folder of images in an app so that the user can browse through them.
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("content://sdcard/Pictures/Album"), "image/*");
startActivityForResult(intent, 0);
This seems to display all photos on the phone instead of the images I have in this album. How can I change this code so that the user can browse through images in a specific folder using the gallery app? The idea behind this is not so that the user can choose an image like I've seen in many examples on here but just simply to browse the images.
you can try this
File root = new File(Environment.getExternalStorageDirectory().getPath()
+ "/myFolder/");
Uri uri = Uri.fromFile(root);
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setData(uri);
startActivityForResult(intent, 1);
Related
Every example i found on net is opening gallery and get images from gallery as result. My need is i don't want result or images to my app. I just want to trigger gallery app with showing particular folder of images. My App Have separate folder to save images. i need to navigate users directly to that path.
Try this code. It will retrieve view pictures under storage/emulated/0/Pictures/AppPics You can change the file path according to your directory path.
File sdDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
File file = new File(sdDir, "AppPics");
if (file.isDirectory())
listFile = file.listFiles();
EDIT: To open your folder using intent
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.withAppendedPath(Uri.fromFile(file), "/AppPics"), "image/*");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
You can try like this,
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = [Uri for your folder];
intent.setDataAndType(uri, "image/*");
startActivity(Intent.createChooser(intent, "Open [App] images"));
I am using the below code which opens up the Gallery, Music Player, Dropbox and Contacts, i want the My Files folder to get open programatically, please let me know if there are any specific intent parameters i need to pass to get the File Manager open.
if it is not possible through intent then please give me a snippet or an hint to open the My Files folder programatically.
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
Intent i = Intent.createChooser(intent, "View Default File Manager");
startActivityForResult(i, CHOOSE_FILE_REQUESTCODE);
Thanks.
You can use this code to file the files.
int PICKFILE_RESULT_CODE=1;
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("file/*");
startActivityForResult(intent,PICKFILE_RESULT_CODE);
this will help you to browse the files from your storage.
Its best that you include a library in your project which handles this scenario.
This worked for me:
This library shows the list of third-party apps. It also has its own file browser for selecting files.
Bad thing is, most Android distributions may or may not ship with a file manager, and even so, may be not with the one which handles CHOOSE_FILE_REQUESTCODE.
So, you are left to create your own file picker activity. Luckily there are many ready made ones available:
http://code.google.com/p/android-filechooser/
https://developers.inkfilepicker.com/docs/android/
If you want to open samsung My Files application try this below code.
Intent intent = new Intent("com.sec.android.app.myfiles.PICK_DATA");
intent.putExtra("CONTENT_TYPE", "*/*");
startActivityForResult(intent, CHOOSE_FILE_REQUESTCODE);
You have to specifically mention the package name of the explorer application. Please find the example below to open a specific folder in ES Explorer.
public void openfolderInexplorer(String path){
Intent intent = this.getPackageManager().getLaunchIntentForPackage("com.estrongs.android.pop");
if (intent != null) {
// If the application is avilable
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Uri uri = Uri.parse(path);
intent.setDataAndType(uri, "resource/folder");
this.startActivity(intent);
} else {
// Play store to install app
intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri.parse("market://details?id=" +
"com.estrongs.android.pop"));
this.startActivity(intent);
}
try this below code. if any file manager available , then it will pop up in a form of menu to choose appropriate for the user.
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("file/*");
startActivityForResult(intent, CHOOSE_FILE_REQUESTCODE);
I would like to open just one image and have pitch-zoom function, so (as I think) easiest way to do that is to open that image in gallery intent. Anybody can share example of how to call gallery intent with particular picture from drawable?
I tried to used something like that but can't make it working (wrong file patch?).
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("com.me.example/drawable/thisimage.png"), "image/*");
startActivity(intent);
According to this post
You should do something like:
String uriStr = "android.resource://"+ "com.example.myapp"+ "/" + R.drawable.photo_h01;
Uri uri = Uri.parse(uriStr);
I have not Eclipse in front of me but that's what I have found on several sources
I want to open a images folder with android built-in gallery.
For example, I have a folder path that contains images, i want to open it with gallery.
I am using this code, it opens the gallery that contains no images.
Any idea?
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(folderImages)),"image/*");
startActivityForResult(intent, 1);
Maybe try this one:
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, ""), 1)
File is present in sdcard/image.jpg
I would like to create my own application (activity).
On a button press, the image stored in the sdcard needs to be displayed using the built-in image viewer.
On pressing the back button from the Image viewer, it should go back to my running application.
Need some help.
you can create an Intent with proper uri and mimetype for this.Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(Uri.parse("file:///sdcard/image.jpg"), "image/jpeg");
startActivity(i);
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, 1);
This code use for display all images from your SD card