Youtube intent filter & scheme - android

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"

Related

Intent Filter to Download Files In Android

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>

Android Intent-Filter Only Launches App When Email Sent from Some Client Sender Apps

my app's file-intent handles attachments with a custom file extension in emails sent from aol.com, but not from Thunderbird. Has anyone had this issue? I see some comments on mime-type handling. My file type is basically text with a ".hmrx" extension.
Is this a matter of adding something more to the intent-filter?
I don't want my app to be suggested for handling general text files... I don't see the problem:
<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="file"/>
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.hmrx" />
<data android:host="*" />
</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:mimeType="application/octet-stream" />
<data android:scheme="content" />
<data android:pathPattern=".*\\.hmrx" />
</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:mimeType="application/octet-stream" />
<data android:scheme="file" />
<data android:pathPattern=".*\\.hmrx" />
</intent-filter>
EDIT:
By the way, I tried adding
<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="content" />
<data android:mimeType="text/plain" />
<data android:pathPattern=".*\\.hmrx" />
</intent-filter>
But then it offers to open regular text files with my app.. which I dont want.
Apparently this is happening because Thunderbird send just about any kind of text as inline instead of as a "real" attachment. Anybody successfully managed this?
Thanks

intent filter link my app to all files

I have a custom file type with the extension .myext.
I've read android doc and many SO posts to understand how to configure intent filter to associate these files to my app. It works but not properly.
When I use this 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:mimeType="application/*" />
<data android:pathPattern=".*\\.myext" />
<data android:host="*" />
</intent-filter>
then it links .myext files to my app, but also every file that has no app assoiated. So I can open .otherext file which I don't want.
Then I found this answer https://stackoverflow.com/a/5097734/575481 which suggest to have multiple intent-filter, So I get :
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:host="*" />
<data android:pathPattern=".*\\.myext" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:host="*" />
<data android:mimeType="application/*" />
</intent-filter>
<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=".*\\.myext" />
</intent-filter>
but this doesn't seem to work for me.
What I want is that : my apps opens only .myext files. Do you have any idea ?
Furthermore I will need to open some other file ext (.myext1, .myext2) , but I guess once I get the proper intent-filter, I just have to duplicate it for the others with the extension, right ?
I got it. In my case I am trying to get a .ppp from e-mail and it was fetching any file.
this is the working filter
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="content" android:pathPattern=".*\\.ppp" android:mimeType="application/ppp"/>
</intent-filter>
on your activity's onCreate put a breakpoint and check the values in
getIntent()
specifically mData should give you what to write for the android:scheme and mType what to write for the android.mimeType

How to appear my app in YouTube share via list?

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.

Handling https schema in intent-filter

I have an intent filter in the Manifest which handles taps on urls, if url match filter data my application starts.
<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" android:host="*" port="8765" android:path="/mypath" />
</intent-filter>
Intent filter works when schema is "http" but if I change it to "https" intent filter doesn't do anything and link starts to load in a browser.
Does anybody know what is the problem here?
Just add an extra data line to your 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" android:host="*" port="8765" android:path="/mypath" />
<data android:scheme="https" android:host="*" port="8765" android:path="/mypath" />
</intent-filter>

Categories

Resources