I need to add my application to share list when I click to "Share" button on some image in gallery (for instance) and then I want to get this image in ImageView.
Share List
Thanks for help!
Intent filters inform the Android system what intents your application is willing to accept.
For images, you’d add the following to your AndroidManifest.xml
<activity android:name=".ui.MyActivity" >
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
When the gallery application tries to share an image by constructing an intent and passing it to startActivity(), your application will be listed as an option in the Android Sharesheet or intent resolver. Upon selecting your app, the corresponding activity (.ui.MyActivity in the example above) will be started. It is then up to you to handle the content appropriately within your code and UI.
More info here
you can check following link here it was mentioned exactly what you want to achieve
Related
I'm working on an android app which could view or edit pdf files.
My app shows up in the "Open file using..." screens.
here is the screenshot
But when I click a pdf file from google files file manager app, it shows "Open with" screen and my app is not there. here is the screenshot
This is my intent filter in manifest.xml :
<intent-filter android:label="View or edit your pdf files">
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT"/>
<data android:scheme="content" />
<data android:mimeType="application/pdf" />
</intent-filter>
How can I make my app visible in the "Open with" screen like Drive Pdf Viewer and WPS Office in the second screenshot ?
I have applied your code in my app and everything worked fine. Don't know what exactly is happening here, but in your case you can define intent filters with lots of actions and data type (category is not necessary in my opinion) to see that if your app can be a candidate to handle the intent. Then in the activity receiving the intent, in the onNewIntent() method, you check all the properties of the incoming intent to see what's is missing in your current solution. All the possible intent's actions can be found in the document (you dont need to define all of them, just add the most popular ones and see the result)
https://developer.android.com/reference/android/content/Intent
What needs to be done to make your app appear as an option app.
For eg, when I select an image file, android shows me a list of applications to open the file with, like Gallery,Photos etc.
I want that android also shows my app in this list.
How to achieve this? I am unable to understand which android classes to use for it? Or do I need to modify manifest file to add some specific intents?
By defining intent filter you can achieve this. You can register your Android components via intent filters for certain events.If a component does not define one, it can only be called by explicit intents. The key for this registration is that your component registers for the correct action, mime-type and specifies the correct meta-data.
Eg.
<activity android:name=".BrowserActivitiy"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http"/>
</intent-filter>
</activity>
Above code will register an Activity for the Intent which is triggered when someone wants to open a webpage.
Source: http://www.vogella.com/tutorials/AndroidIntent/article.html
I am trying to implement a new feature for my android application.
scenario :
when some event occurs, the camera sends an email to my (Gmail) account.
on opening the mail, it will have a link (html).
when user clicks on that link, it should launch my application Home activity.
I need to understand :
how to create that html link.
how can i make the link to launch my application Home activity.
kindly help me to understand what all things i need to do in my application.
I used "Blackbelt's" user comment and i was able to get the intent html link working.
But my problem is : i want to use a custom scheme "mobile" instead of "http"
I am using Gmail to use the link. But when i send using custom scheme. Gmail doesnt recogonise as hyperlink. So i cannot click on the link.
Please help me how to use a custom scheme. with gmail
you need to register an intent-filter for your Activity on the AndroidManifest.xml file, defining a custom url. . E.g.
<activity android:name="path.to.YourActivity" >
<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:scheme="https"
android:host="it.is.my.app" />
</intent-filter>
</activity>
So if you press on a link like https://it.is.my.app, you should be prompted with the android intent chooser, with your app
I have this declared in my AndroidManifest.xml:
<activity
android:name="x.y.z.MyActivity"
android:label="#string/app_name"
android:theme="#style/MyTheme" >
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
What I am trying to do is to register my activity for sharing of images from other apps. This works for normal images from the Gallery but my app doesn't appear as option for sharing of images from the Gallery that are up on Picasa. I'm not sure what else to add to my intent-filter to cover also this use case.
Try
<data android:mimeType="*/*" />
and debug/log the type of the Intent sent by Picasa to add it to your intent filter.
I've used Intent Intercept app to intercept the intent from the Gallery.
Unfortunately I see that the mime type is text/plain and there is an extra that contains the link to the image. I can't use this mime type because my app is only able to handle images and not text (the app might show up in apps that share text and obviously I don't want that).
Short answer: this cannot be done if you don't also implement sharing of text.
I want users to see my app in the list when they are selecting an image from another app.
Lets take the Facebook app for example. You can select an image to attach to a post, which brings up the "Complete action using" dialog that normally just contains "Gallery". I want my app to appear in this list.
(Most similar questions are regarding picking an image from my own app, which is not at all what I wish to accomplish)
Add a intent filter to the activity that you wish to start. The correct intent for Facebook is PICK:
<intent-filter>
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
However, this does not cover the same scenario for the Tumblr app, which apparently uses some other intent for the same type of action (attaching a photo).