I want my app to open on http://www.example.com and https://www.example.com.
This works:
<data
android:host="www.example.com"
android:path="/"
android:scheme="http"/>
<data
android:host="www.example.com"
android:path="/"
android:scheme="https"/>
Is it possible to catch both with one entry? I tried:
<data
android:host="www.example.com"
android:path="/"
android:scheme="http*"/>
but this catches only the http link, not the https one.
So I know how I can handle bot variants, but want to use the most concise writing possible.
This seems to do the trick for me:
<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.mywebsite.com" />
<data android:pathPrefix="/mypage.php" />
</intent-filter>
You can use seperate <intent-filter> for both
<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.com"
android:path="/"
android:scheme="http"/>
</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:host="www.example.com"
android:path="/"
android:scheme="https"/>
</intent-filter>
Related
I want to make intent-filter which can detect urls like this one:
http://www.example.com/?p=12345
I tried with this code:
<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="www.example.com"
android:pathPattern="/\\?p=.*"/>
</intent-filter>
But it doesn't work. Can anybody help?
I found answer
<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.com"
android:pathPattern="/*"
android:scheme="http" />
<data
android:host="www.example.com"
android:pathPattern="/.*/"
android:scheme="http" />
</intent-filter>
I wanted a custom extension file (*.xyz) to be opened through my app. Inside the application manifest file I am writing the following:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="http" android:host="*" android:pathPattern=".*\\.xyz" />
<data android:scheme="https" android:host="*" android:pathPattern=".*\\.xyz" />
<data android:scheme="content" android:host="*" android:pathPattern=".*\\.xyz" />
<data android:scheme="file" android:host="*" android:pathPattern=".*\\.xyz" />
</intent-filter>
After that I will install my application on the device and will send a mail containing the Sample.xyz mail as an attachment. When I try to tap on attachment in the mail client to open the attachment then it will give an error called
No app can open this attachment for viewing
Even if when I download the attachment and then try to open it then it will give an error
Can't open file
Can anyone suggest what might be going wrong ?
your filter does not match as it is not http https file and content at the same time - you will need different <intent-filter>'s for this - have a look here:
https://github.com/ligi/PassAndroid/blob/master/src/main/AndroidManifest.xml
and just do what I do for *.pkpass for *.xyz like so:
<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="*"
android:pathPattern=".*\\.xyz"
android:scheme="http" />
</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:host="*"
android:pathPattern=".*\\.xyz"
android:scheme="https" />
</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:host="*"
android:pathPattern=".*\\.xyz"
android:scheme="file" />
</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:host="*"
android:pathPattern=".*\\.xyz"
android:scheme="content" />
</intent-filter>
Ive made an web browser, when I click on a link from gmail for example then it asks how I want to open that link-what browser I want to use (chrome/firefox etc). How do I make it so it asks if it wants to open it with my browser?
Thanks in advance.
Add the appropriate <intent-filter> elements to your activity, and support them properly.
For example, here are relevant <intent-filter> elements used by the AOSP Browser app:
<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:scheme="about" />
<data android:scheme="javascript" />
</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:scheme="https" />
<data android:scheme="inline" />
<data android:mimeType="text/html"/>
<data android:mimeType="text/plain"/>
<data android:mimeType="application/xhtml+xml"/>
<data android:mimeType="application/vnd.wap.xhtml+xml"/>
</intent-filter>
I'm creating an rss aggregator for my Android phone. I'd like to be able to subscribe to an rss feed from the browser since most websites have a subscribe via rss button.
How can I build an intent filter to receive those links?
This question was similar and showed how to create an intent filter to handle browser links:
Make a link in the Android browser start up my app?
However, I don't know how to make it specific to rss feeds.
As an attempt I tried this filter:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data android:mimeType="application/rss+xml" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
Am I on the right track? What should I be filtering on?
These 3 filters seem to be the ones used by GoogleListen and GoogleReader apps:
<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:host="*"/>
<data android:pathPattern=".*\\.xml"/>
<data android:pathPattern=".*\\.rss"/>
</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:host="feeds.feedburner.com"/>
<data android:host="feedproxy.google.com"/>
<data android:host="feeds2.feedburner.com"/>
<data android:host="feedsproxy.google.com"/>
</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:mimeType="text/xml"/>
<data android:mimeType="application/rss+xml"/>
<data android:mimeType="application/atom+xml"/>
<data android:mimeType="application/xml"/>
</intent-filter>
Turns out there's a lot of different ways podcasts can be set up so each intent filter will only work for some of them. A lot of different filters need to be used to get the desired effect over most subscribe links.
Here's some of the filters I found that worked:
<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="itpc" />
<data android:scheme="pcast" />
<data android:scheme="feed" />
<data android:scheme="rss" />
</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" android:host="*"
android:pathPattern=".*xml" />
<data android:scheme="http" android:host="*"
android:pathPattern=".*rss" />
<data android:scheme="http" android:host="*"
android:pathPattern=".*feed.*" />
<data android:scheme="http" android:host="*"
android:pathPattern=".*podcast.*" />
<data android:scheme="http" android:host="*"
android:pathPattern=".*Podcast.*" />
<data android:scheme="http" android:host="*"
android:pathPattern=".*rss.*" />
<data android:scheme="http" android:host="*"
android:pathPattern=".*RSS.*" />
</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="text/xml" android:scheme="http" />
<data android:mimeType="application/rss+xml" android:scheme="http" />
<data android:mimeType="application/atom+xml" android:scheme="http" />
</intent-filter>
Am I on the right track?
Yes. However:
You don't need the scheme
You are missing the android: prefix in front of scheme, anyway
type should be android:mimeType
Here is a sample application that demonstrates, among other things, responding to links on PDF files.
Could it be that the server doesn't send the right mimetype?
Experiment by adding:
<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=".*\\.rss" />
<data android:pathPattern=".*\\.xml" />
</intent-filter>
Edit:
It's a bit tricky to compose the right set of intent-filters, there's a lot of early returns in the matching algorithm:
https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/content/IntentFilter.java
In your case, the mimetype must match exactly which is 'application/rss+xml' do your sources return that mimetype in the message header?
URL url = new URL("http://www.engadget.com/rss.xml");
URLConnection conn = url.openConnection();
System.out.println("Content-Type:"+conn.getHeaderField("Content-Type"));
Try to:
Make broader filters
Add multiple filters.
This question has been asked [numerous times] before, but I have not seen any definitive answers, or examples of code that actually works.
I would like to associate an Activity with a particular file type.
For discussion, assume that I want my Activity to be associated with PDFs.
Here is what I currently have. I have experimented with many different values and combinations of values in the intent-filter, but I have yet to get my Activity to start when a PDF is selected.
<activity name="com.mycompany.MyActivity">
<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="application/pdf" />
<data android:pathPattern="\\*\\.pdf" />
<data android:host="*" />
</intent-filter>
</activity>
Does anyone know how to actually make this work?
Have you tried with that simple version :
<activity name="com.mycompany.MyActivity">
<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/pdf" />
</intent-filter>
</activity>
Your pathPattern is definitively wrong and you are restricting it too much with the mimetype.
Try the following:
<activity name="com.mycompany.MyActivity">
<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=".*\\.pdf" />
</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/pdf" />
</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=".*\\.pdf" />
</intent-filter>
</activity>
To open both local and remote pdf files I'd do:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/pdf" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" android:host="*" android:pathPattern=".*\\.pdf" />
</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" android:host="*" android:pathPattern=".*\\.pdf" />
<data android:scheme="https" android:host="*" android:pathPattern=".*\\.pdf" />
</intent-filter>