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
Related
I want to open the default gallery app to a folder (named fooo) in the primary storage. I thought the easiest way would be to use Intents. When I use this code for my intent, the gallery app opens but it shows no image. I check with file explorer and there are images.
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath()+"/fooo/");
intent.setDataAndType(uri, "image/*");
startActivity(intent);
First, there is no requirement for any ACTION_VIEW activity to be able to handle a directory as the Uri.
Second, your MIME type is incorrect, as a directory is not an image.
Third, your Uri is invalid, because it lacks a scheme. Replace:
Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath()+"/fooo/");
with:
Uri uri = Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "fooo");
We are trying to set the downloaded image (and stored inside galley under our own folder) as wallpaper using our application, and its working using the below code.
public void Set_Current_wallpaper() {
File f = new File(mCurrentWallpaperPath); // mCurrentWallpaperPath is Our folder inside gallery
Uri contentUri = Uri.fromFile(f);
Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setDataAndType(contentUri, "image/*");
intent.putExtra("mimeType", "image/*");
startActivity(intent);
}
Problem is right now when above code is running below is how set wallpaper application screen looks like, But if we directly open the image from gallery and set as wallpaper, this is the wallpaper set screen looks like. Why is it opening in different way? Attaching the screens Actual vs Expected here.
Actual Result
Expected Result
Have you tried WallpaperManager?
WallpaperManager wallpapermgr = WallpaperManager.getInstance(this);
wallpapermgr.setBitmap(yourbitmap);
Within my fragment, I am trying to start an intent to display a local image with a gallery app on my phone.
The three lines in question are
string path = String.Format ("content:/{0}.jpg", CacheController.Static.GetPath (m));
Android.Net.Uri uri = Android.Net.Uri.Parse(path);
StartActivity (new Intent (Intent.ActionView, uri));
the value of path is content://data/data/Appname.subname/files/cache/107.jpg.
I tried using file:/ at the beginning of the Uri but that didn't help.
You are trying to share an image that is in a folder private to your app. You first need to copy the image to a public folder and make an intent pointing to that image. Have a look here and here
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);
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