I'm using an intent with ACTION_VIEW to view a photo on android, but it doesnt open with any of the options the gallery has when viewing other pictures (specifically share). Anyone know how to make it have those options?
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(location, mimeType);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
gives me a viewer like this:
but just viewing in the gallery, i get all this stuff:
these issues are similar, but had no answer
Intent Action_View for image opens gallery with no delete option
Android image intent : sharing/editing options
and the interesting thing is both of those issues talk about those options ALREADY being available... so im not sure what im doing wrong.
but it doesnt open with any of the options the gallery has when viewing other pictures (specifically share)
There are ~2 billion Android devices, made up of thousands of device models. Many of those device models will ship with 1+ activities that support your Intent structure, and many of the actual devices will have other apps that support it, installed by users. None have to offer a "share" option.
Anyone know how to make it have those options?
Strictly speaking, you can't.
Those image-viewing apps were written by developers, and those developers can do whatever they want. Perhaps there are different activities for internal use vs. ACTION_VIEW. Perhaps it is the same activity, but they only offer those options when the activity is reached internally (vs. from outside apps via ACTION_VIEW). Perhaps they only share certain Uri schemes or MIME types. Perhaps they do not share images because it is Tuesday.
And, again, the behavior will be different on different devices, based on which image-viewing apps the user has and chooses to use.
If you want to have a "share" option, put it in your app. If you want that share option to be on the screen that shows the image, show the image in your app. Right now, you are delegating all of that to third-party apps, and those apps do not have to do what you want.
Related
I'm using ACTION_OPEN_DOCUMENT like this:
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
launcher.launch(intent);
The launcher using ActivityResultContracts.StartActivityForResult.
A picker appears, and the sidebar look like the same one you see in the Files app, showing Recent, Images, Documents, Downloads and SDCARD. This is good.
Now if I restrict it to only certain mime types by adding
intent.putExtra(Intent.EXTRA_MIME_TYPES, arraylist-of-my-types);
the sidebar looks quite different, only showing Images and Documents.
Is it possible to restrict the types without affecting the sidebar? The user will want to know where the document they choose is located, especially when using an external SD card.
TL;DR: No.
A picker appears, and the sidebar look like the same one you see in the Files app, showing Recent, Images, Documents, Downloads and SDCARD.
What the documents UI looks like will vary by device model, and there are tens of thousands of device models. The specific sidebar (or equivalent) options can vary by user. The documents UI also may not exist, especially for edge device types (watch, TV, car).
Now if I restrict it to only certain mime types... the sidebar looks quite different, only showing Images and Documents.
See above.
Is it possible to restrict the types without affecting the sidebar?
There may not be a sidebar. What appears in the sidebar (or any equivalent) is up to the developers of the document UI for that device model. You and I do not control it except in very general terms, and then not in any manner that is necessarily consistent across device models.
In my app, I am trying to find no. of files can be shared by an application. Like user can share only 10 images with WhatsApp. I want to know this before I could start sharing the image so that I could notify to user and avoid App launch call.
As of now, I can know only either App can handle single or multiple file share using intent action using ACTION_SEND and ACTION_SEND_MULTIPLE but don't know how many files can be shared.
Is there a way to figure this out?
Is there a way to figure this out?
No.
I've seen that Android automatically generates a thumbnail when taking a photo, and saves it as an extra with the key "data". Is it possible to disable that action, as to save space in the device?
I've seen that Android automatically generates a thumbnail when taking a photo, and saves it as an extra with the key "data".
No, it does not. Camera apps may generate thumbnails and put them in a data extra in the Intent used with setResult(). Android, the operating system, does not.
Is it possible to disable that action, as to save space in the device?
I do not know what "space" you think you will "save". That thumbnail is held briefly in system RAM. It is not stored on disk.
If you are a programmer, and if you are writing an Android app, and if you are using an ACTION_IMAGE_CAPTURE Intent with startActivityForResult() to invoke a third-party camera app, then you can include EXTRA_OUTPUT to indicate where you want a full-sized image to be written. According to the ACTION_IMAGE_CAPTURE specification, the data extra is not needed in that case. Some camera apps will then skip that extra.
However, developers of third-party camera apps are welcome to do whatever they want. If they want to create the data extra on every ACTION_IMAGE_CAPTURE request, that is their decision to make, as they are the ones writing the camera apps.
Hey I'm stuck with this problem for quite a while
I need to have a backround activity in android which will be running to detect any photo/video activity, the minute a photo or video is taken it should make an entry into a text file:
The entry should look like this : [uri_of_new_photo, time, gps-location]
What are the possible ways in which i can achieve this, I was looking at the BroadcastReciever, but was not sure if that would work.
Are there any tutorials/links which can give me a solution. A direct solution to this problem would be great!! (rather than alternatives, as this is a small part of a bigger project)
What are the possible ways in which i can achieve this
Technically, it's not possible. Anyone is welcome to write a camera application that takes photos or videos and does not tell you about them.
I was looking at the BroadcastReciever, but was not sure if that would work.
I am not sure what "the BroadcastReceiver" is that you are referring to.
You are welcome to use FileObserver to try to monitor likely places for photos and recorded videos. However, there is no guarantee that apps will write their photos or recorded videos in the places that you are looking. And, just because there is a new file in one of those directories does not mean that the user took a photo or recorded a video -- they could have simply copied a file into that directory, or obtained the file from the Internet (e.g., Flickr sync). And, this will only work while your app is running.
You are welcome to use a ContentObserver on MediaStore. It will suffer from the same basic problems as would the FileObserver approach that I mentioned.
If you want to reliably log information about the time and location of photos and videos, write your own camera app.
Im trying to launch an application from another one. Ive used the fingerpaint api demo and added a save and some different brushes and Id like the user to be prompted on saving the picture to select something like photoshop to do color correction of photomanipulation to the photo and once they are done with the photo and its saved in photoshop have the fingerpaint app reopen with the photo they just manipulated in the screen and ready for them to add more to if they chose to do so.
Will I have to set a background activity to read the photoshops state and when it saves? Thats what Im thinking I will have to do but Im not sure at this point.
Im not asking for some one to code it out for me but if any one has an idea of how or where I can see an example of an app opening another that would be awesome.
( and please do not be so vague as to say look at the android.com dev section as there is WAY to much info to look through on there. I spend half my day on there already :p )
Intents are used to launch other activities. Best way would be to save the image and get the uri for the image.
Intent i = new Intent(Intent.ACTION_EDIT, imageUri);
this.startActivity(i);
That will launch whatever activity that can handle that uri and intent type. You can also use createChooser to give the user the option to pick an Activity. (similar to have the share option works in most apps).
To do the saving recognition I'm not sure if startActivityForResult would do what you want. it depends on how the Photoshop app is setup.