How to make my Android App to act as Image Picker [duplicate] - android

This question already has answers here:
What intent-filters must my app cover to appear in chooser when requestion an image from an external app?
(4 answers)
Closed 8 years ago.
I am developing an Android App which contains image collection with different type of Images.
I want my app to act as Image Picker.
For example when a user want to pick an Image to post on facebook or wahtsapp,chooser dialog gets opened with gallery app option and user select the image to post from gallery. What I want is my app should be listed in Image Picker along with Gallery so that user can select image from my app.
Thanks

Its quite simple. You can register the IntentFilter for that corresponding mime type inside your Activity tag AndoridManifest.xml and your app will also be listed among the apps which can be used to pick images. Code:
<intent-filter>
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>

Related

Is it possible to only show your app as a receiver in the share sheet for a certain number of attachments for Android?

Hi I want my app to show in the share sheet only if the user has selected 5 or less files but I am not sure if that is possible. So far I have the following code in the manifest so that my app will show when the user selects multiple attachments. I don't want my app to deal with it when the user selects my app, I just want my app to not show up in the first place on that condition.
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>

Activity with "android.intent.action.SEND" intent filter is not showing up in list when sharing photo from stock Google Photos app

I have an Android app with an activity with an intent filter set to receive photos and videos. It is declared in my AndroidManifest.xml as so:
<activity
android:name="com.foo.gallery.app.activity.RecievePhotosActivity"
android:label="#string/photoapp_gallery_common_app_name"
android:exported="true"
android:configChanges="orientation|keyboardHidden|screenSize" >
<intent-filter >
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
<data android:mimeType="video/*" />
</intent-filter>
</activity>
However, when going into the stock Lollipop Photos app and sharing a photo, my app does not appear in the list.
My app does appear in the share list when sharing from other apps, like OneDrive, Dropbox, and Quickpic. The stock Photos app is the only one I've found so far where my app doesn't show up.
I found the problem. My app was named "Photos" - the same as the stock Photos app. I guess Google decided to hide apps with the same name in the share list.

Android: Accept data from other apps

I am working on article reader and am trying to accept article urls from other apps (similar to how Pocket, Evernote are listed in the Share via menu as "Add to X").
My activity contains the following in the manifest:
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAUlT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="text/*" />
</intent-filter>
But so far the app only shows up in the "Share via" list for Chrome(Android), but not for other apps that show articles (for example, it doesn't show up in the share list in the "Reddit Now" app whereas other apps like "Pocket" or "Evernote" do).
What do I have to specify to accept any kind of information that may potentially contain an article url?

share via (Gallery )activity not getting closed after sharing the image

I have added my app option in share via option that comes when we share any image in gallery through share via option. I am able to see my app in share via option. But the problem is once the image is shared and after that the gallery is opened then the gallery still shows the app activity which means gallery activity is not finished even after sharing the image. How to overcome this problem ?
Here is the line of code I've added in activity tag in Manifest file :
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>

Launching custom Android application from Android browser / Chrome

First of all, my question is extremely similar to this, this and this. The Android documentation for what I'm trying to achieve is here. I couldn't get this to work using these resources so please don't mark this as duplicate as it is not.
I have a website and an Android application. The user will be able to scan QR codes that contain links like http://mywebsite.com/map/. When the user tries to open this link, I want Android to show him a chooser dialog where he can choose to open that link using my application. If my application is not installed, it should proceed to the specified website.
I know Chrome allows this by opening the chooser dialog when the user navigates to that address. For example, try downloading the Stack Exchange app and going to this question in Chrome. It will show this:
I have added the following code in AndroidManifest.xml after following the suggestion in the above-mentioned answers:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="mywebsite.com"
android:path="/map"
android:scheme="http" />
<data
android:host="mywebsite.com"
android:path="/animals"
android:scheme="http" />
<data
android:host="mywebsite.com"
android:path="/articles"
android:scheme="http" />
</intent-filter>
Also, I have tried adding android:mimeType="text/plain" to data but it didn't help.
The problem is that when I go to http://mywebsite.com/map or http://mywebsite.com/map/ Chrome just opens the webpage without showing the chooser dialog.
I would like to mention:
following the Android documentation, I have added this code inside one of the activity structures in AndroidManifest.xml. As I am not sure this is the perfect place to add it, I have also tried adding it outside the application structure and directly inside the application structure but it didn't work
this is the only code I have implemented for this to work. If something else is needed please let me know. From what I understand, adding a href to the webpage is only needed when using custom schemas
I do not want to use a custom schema in order to achieve this
I am developing on a Nexus 4, running Android 4.4.2 (latest)
You need to set it up like this :
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="example.com"
android:pathPrefix="/someresource/"
android:scheme="http" />
<data
android:host="www.example.com"
android:pathPrefix="/someresource/"
android:scheme="http" />
</intent-filter>
Notice that in your case, you would need to use android:pathPrefix instead of android:path.
Just to be sure, you should reset the preferences for your app in case you have accidentally set it to always open the link in chrome rather than show the chooser dialog. Once "Always" is used to open the matching uri, it will never show the chooser.
Second, you can have as many data elements in the intent filter as your want, but it is not necessary to repeat information. You can do the same thing like this:
<data android:host="mywebsite.com"/>
<data android:scheme="http"/>
<data android:path="/map"/>
<data android:path="/animals"/>
<data android:path="/articles"/>
But note that for the path, you can just use a wildcard
<data android:path="/.*"/>
Consider adding an additional
<data android:host="www.mywebsite.com"/>
And finally you may not want to show the chooser dialog but open a specific app intent/activity directly. On your website, if you detect the android user agent, you can create a link url this way:
<a href="intent://mywebsite.com/articles#Intent;package=com.myapp;scheme=http;end;"/>
See here for more details How do I open any app from my web browser (Chrome) in Android? What do I have to do with the A Href link?
Note that with this method if the app is not installed the user will be taken to the Google Play store for the specified app package.
If you are still having problems, check your intent filter priority. http://developer.android.com/guide/topics/manifest/intent-filter-element.html
In my case site URL is: http://www.example.org/mobile/
so putting these code into AndroidManifest.xml inside activity
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.example.org"
android:pathPrefix="/mobile/"
android:scheme="http" />
</intent-filter>
Here,
scheme -> Protocol of particular site
host-> Exact site url with WWW
pathprefix - > Your site's sub path if available
Now,
You can search with chrome / etc android browser'search box like example then open chosen dialog ..!!

Categories

Resources