YouTube App for tablets has a sharing-option. For example: I watch a video in the YouTube app and click the button to share. Bluetooth, Googlemail, and Dropbox appear for me. I wonder how i can list my app there? Which intent-filter has my app to have?
Here i have tried. But this is not working for me. I am using Android Kitkat version.
<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:mimeType="audio/*" />
<data android:mimeType="video/*" />
<data android:mimeType="text/*" />
<data android:scheme="content" />
<data android:scheme="file" />
</intent-filter>
You have to put this intent filter inside an Activity tag in your Manifest file...
<intent-filter>
<action
android:name="android.intent.action.SEND" />
<category
android:name="android.intent.category.DEFAULT" />
<data
android:mimeType="image/*" /> /* WRITE THE CORRECT TYPE */
</intent-filter>
Then you have to develop the way your Activity handles the data from the current intent.
Related
My app has an activity for opening YouTube links, with intent filters which I've copied from NewPipe. It works fine: when I click on a YouTube link, Android asks me which app to use, and my application appears in the list. The problem is, it asks me this every time, even after I go to the settings and select "Open in this app".
NewPipe works as expected: after choosing "Open in this app", it's used to open YouTube links every time, without asking.
Here's the AndroidManifest portion for my activity, copied from here:
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<!-- Youtube filter, copied from NewPipe -->
<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="http" />
<data android:scheme="https" />
<data android:host="youtube.com" />
<data android:host="m.youtube.com" />
<data android:host="www.youtube.com" />
<data android:host="music.youtube.com" />
<!-- video prefix -->
<data android:pathPrefix="/v/" />
<data android:pathPrefix="/embed/" />
<data android:pathPrefix="/watch" />
<data android:pathPrefix="/attribution_link" />
<!-- channel prefix -->
<data android:pathPrefix="/channel/" />
<data android:pathPrefix="/user/" />
<data android:pathPrefix="/c/" />
</intent-filter>
<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="http" />
<data android:scheme="https" />
<data android:host="youtu.be" />
<data android:pathPrefix="/" />
</intent-filter>
</activity>
I haven't done any tests to conclusively answer this, but I think in my case this was because my app didn't have a "main activity". I've added a proper activity with categories LAUNCHER and DEFAULT and now the app behaves as I expect.
This could be a security feature, to prevent "hidden" apps from hijacking somebody's intents.
I want my application to be on the list to open .gpx from anywhere in the android environment. the none of the intent filters I tried didn't work, what do I need to add to make it work?
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
<data android:host="*" />
<data android:pathPattern=".*\\.gpx" />
</intent-filter>
I'm trying to make my app appear in this screen:
Download Apps List
So that I can download files using my app.. I added the following Intent filter into my manifest:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/*" android:host="*" android:pathPattern=".*.ext" />
</intent-filter>
But this has no effect at all.. Is there a way to do that ?
To use android:host and android:pathPattern, you need android:scheme as well.
Try to change your intent-filter to this one :
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" /> //or content
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.ext" />
<data android:host="*" />
</intent-filter>
Im trying to receive an intent from the Youtube App. I.e. when i press share it should list my app on the apps ready to accept this intent. But none of these works
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
<data android:mimeType="video/*" />
<data
android:host="*"
android:scheme="youtube" />
<data
android:host="*"
android:scheme="vnd.youtube" />
</intent-filter>
or with action VIEW
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
<data android:mimeType="video/*" />
<data
android:host="*"
android:scheme="youtube" />
<data
android:host="*"
android:scheme="vnd.youtube" />
</intent-filter>
Any idea about how to get the intent as well once sent?
Thanks
The YouTube app sends text/plain data, so register your activity as a receiver of that mimetype:
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="www.youtube.com"
android:mimeType="text/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="m.youtube.com"
android:mimeType="text/plain" />
</intent-filter>
You seem to be quite confused. The intents you are using seem to be the intents that an app like the YouTube app itself would use to open videos. What you want is to share a YouTube video, i.e. a link, so as the other answers mention, you should declare a text/plain intent-filter.
However, this intent-filter will capture all text/plain content and not only the ones that come from YouTube. See: Intent-filter: How to accept only "text/plain" intents containing the word "spaghetti"
I want my intent to be launched when the user goes to a certain url: for example, the android market does this with http://market.android.com/ urls. so does youtube. I want mine to do that too.
I did it! Using <intent-filter>. Put the following into your manifest file:
<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.youtube.com" android:scheme="http" />
</intent-filter>
This works perfectly!
You might need to allow different combinations of data in your intent filter to get it to work in different cases (http/ vs https/, www. vs no www., etc).
For example, I had to do the following for an app which would open when the user opened a link to Google Drive forms (www.docs.google.com/forms)
Note that path prefix is optional.
<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="http" />
<data android:scheme="https" />
<data android:host="www.docs.google.com" />
<data android:host="docs.google.com" />
<data android:pathPrefix="/forms" />
</intent-filter>