Browser Selection Android - android

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>

Related

Open app activity if clicked on a specific file in file browser

I want to open my activity if user clicks a specific text file in file browser like deep link.
Here is my code
<activity
android:name=".debug.DebugActivity"
android:label="#string/debug_label"
android:screenOrientation="portrait">
<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:host="*/*" />
<data android:pathPattern =".*\\.txt" />
<data android:host="*" />
</intent-filter>
</activity>
How can I do that?
Thanks in Advance
<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="file" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:mimeType="text/html" />
<data android:mimeType="text/plain" />
<data android:mimeType="application/xhtml+xml" />
</intent-filter>
I got the solution with this

Android : Define my App to Firefox browser as download manager

I'm programming a download manager application in android .
I create this Intent-Filter in Manifest :
<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" />
<data android:scheme="http" />
<data android:scheme="ftp" />
<data android:host="*" />
Google Chrome define my app as a download manager successfully but Mozila Firefox not show my App in Intent dialog by clicking each link.
Please help me to fix this
I found my solution .
Put here for use anyone :
Add this Lines in you manifest :
<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:mimeType="*/*" />
</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

Launch application from gmail app

I have a android application to preview .dst file type,i am able launch the app by clicking on file from the file explorer i did it by following 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="file" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.DST" />
<data android:host="*" />
</intent-filter>
now i need to launch the app from the default gmail app,i think i need to change the
android:scheme="file"
tag ,please help me with the proper scheme for gmail application..
update the manifest as below
<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="*" />
<data android:mimeType="application/octet-stream"
/>
<data android:pathPattern=".*\\.DST" />
</intent-filter>

How to open my Android app when rss link is opened in browser?

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.

Categories

Resources