I am using the following code to open android gallery when an image is clicked in my app
Intent intent = new Intent (Intent.AUri.parse( "content://media/internal/images/media" ));
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
mActivity.startActivity(intent);
how can i modify my code to open a particular image directory or a particular image
According to me you should try this.
In your MainActivity introduce a method to create intend for that
and use syntax
intent.setComponent(new ComponentName("com.example.administrator.YOUR GALLERY APP NAME","com.example.administrator.YOUR APP.MainActivity"));
where com.example.administration is the initial name of your package
Related
I use following code to open an image in the gallery:
public void onItemClicked(PictureItem item){
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri imageUri = FileProvider.getUriForFile(getApplicationContext(), "myapp.fileprovider", new File(item.uri.getPath()));
intent.setDataAndType(imageUri, "image/*");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(intent);
}
This shows my photo in the gallery, but in a 'read-only' mode. I want to be able to delete the image from there, just as if I opened it directly in the gallery.
Which action do I have to use for that? I do not want to use pick, just normal view with the option to delete. I tried ACTION_EDIT but it's not supported (and not quite the right choice neither ...).
I use following code to open an image in the gallery
First, there are hundreds, if not thousands, of "gallery" apps available for Android.
Second, your code simply asks to view an image (with a broken Intent due to your wildcard MIME type). There is no requirement for the app that responds to be a "gallery" app.
I want to be able to delete the image from there, just as if I opened it directly in the gallery.
Then implement that yourself, in your own app, and get rid of the ACTION_VIEW Intent.
Which action do I have to use for that?
There is no Intent action that says "please display this image, but only if you are a gallery app, and, oh, by the way, you must offer a delete option", which appears to be what you want.
I want open my images with gallery app but show this error
Cannot generate thumbnail
my code:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(Environment.getExternalStorageDirectory().getPath()+"/Connection/Picture/"+listItems.get(position)), "image/*");
startActivity(intent);
Is there another way to show image with default android app?
Notice:
1.when I use a file manager to open it , it open successfully
2.when I use my app to open image ,if I choose another app to open it,it open successfully
3."listItems.get(position)" is imagename forexample "2361386837.jpg"
Can You help me?
I have an android app that lists items with url links and on clicking opens the pages using uri,
as below
String url = "http://www.example.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
I would like to open only for example a video or image in that page but not the whole of it.
Is that possible in android?
I got what you want to ask.
NO, it is not possible with Intent to open a part of a webpage, it will open entire page,
I suggest you to
1. download and save the image to your drawable folder.
2. create a new actvity , and in the xml associated with that activity add a imageview
3. place your image in that imageview
4. and on the click of the link start the activity with the intent
I would suggest to either use an ImageView (load the image into it - Download image for imageview on Android) or a VideoView (as stream - http://code.tutsplus.com/tutorials/streaming-video-in-android-apps--cms-19888).
It's not possible with an intent.
Currently I have the following:
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(mediaLoc)), "image/" + type);
context.startActivity(intent);
This was because the app used to download images from urls and saved them into the sdcard before viewing. But now I want to change the implementation to show the image from a url in the default image viewer when ACTION_VIEW is called and give them the option to save. Is this possible with ACTION_VIEW? I'm asking because I wish to use the default image viewer in the phone as it has already handled the zoom functions.
You would have to make a custom action_view for it.
How can I use default Android gallery to display only application's photos? Basically I need to display only my application photos on gallery.
Many Thanks
Sure! You have to parametrize the Intent that is launching the Gallery Application: Set Action to Intent.ACTION_PICK. Set MIME type to one of the image types, or image/* . Set the data to the file to be shown's Uri.
Intent galleryStarter = new Intent();
galleryStarter.setAction(Intent.ACTION_PICK);
galleryStarter.setType("image/*");
galleryStarter.setData(Uri.fromFile(imageFileToShow));
context.startActivity(galleryStarter);