2

If someone clicks on a link it says 'open with' and you can choose between 'Firefox,Chrome...' How I can put my app there and if someone clicks on my app name ... my app gets started with a parameter which contains this link.

I'm sorry if this is the wrong section.

  • Not sure but can help you Refer this [open here](http://stackoverflow.com/questions/11152838/why-isnt-my-app-on-the-list-of-apps-to-open-txt-file) – Abhilash Harsole Dec 17 '16 at 12:06
  • have you heard of intentFilter before? do a little search and phrase your question about it, – Elltz Dec 17 '16 at 12:06

2 Answers2

1

use <intent-filter>

DESCRIPTION: Specifies the types of intents that an activity, service, or broadcast receiver can respond to. An intent filter declares the capabilities of its parent component — what an activity or service can do and what types of broadcasts a receiver can handle. It opens the component to receiving intents of the advertised type, while filtering out those that are not meaningful for the component. Most of the contents of the filter are described by its <action>, <category>, and <data> sub elements.

Here is an example

<a href="http://stg.bbc.in/press-rel/abc.html">click me!</a>

AndroidManifest.xml looks like this:

 <activity
    android:name=".DashBoard"
    android:label="@string/title_activity_dash_board"
    android:exported="true"
    android:theme="@style/AppTheme.NoActionBar">
    <intent-filter>
        <data
            android:host="www.bbc.in"
            android:pathPrefix="/"
            android:scheme="https" />
        <data
            android:host="www.stg.bbc.in"
            android:pathPrefix="/"
            android:scheme="http" />
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
    </intent-filter>
</activity>

Note: Order of the intent flags might cause a problem so use like above

"I suggest you simply make another <intent-filter> with the new sub elements in that tag to avoid the problems" look here

Community
  • 1
  • 1
Charuක
  • 12,953
  • 5
  • 50
  • 88
  • `href="market://`??? That link will not be catched by a http scheme intent-filter i think. – greenapps Dec 17 '16 at 12:21
  • that will start up the Android Market that points to google play search bar real link will be https://play.google.com/store/search?q=market%3A%2F%2Fsearch%3Fq%3Dpname%3Acom.nytimes.android&c=apps&hl=en , same thing you can find if you type market://search?q=pname:com.nytimes.android on google play search :P – Charuක Dec 17 '16 at 12:27
  • Can be. But OP wants his app to be in the list with a http:// href. No idea why you come up with market. Its confusing. – greenapps Dec 17 '16 at 12:32
  • Thanks. `android:host="www.bbc.in"` ?? Why that? What does it do? Wont it restrict to that host only? OP did not ask for that. Confusing. – greenapps Dec 17 '16 at 12:37
  • thank you for your help but how I can call my app with the url as parameter – Akin Unknown Dec 17 '16 at 13:35
  • @Akin Unknown have a look here ? http://stackoverflow.com/a/9761241/5188159 is that what you want – Charuක Dec 17 '16 at 13:47
  • I just see that everyone misunderstood me...my fault I had to ask with pictures...but good to know what I just learned ! It's important for my future programming – Akin Unknown Dec 17 '16 at 13:55
  • [link](http://i0.wp.com/gwhaleapk.com/wp-content/uploads/2015/07/Open-with.jpg) I wanted my app to appear there if people open a url for example in google...it asks me to open it with 'Firefox' 'Chrome' bla bla... – Akin Unknown Dec 17 '16 at 13:58
1

You need to add the following <intent-filter> to the Activity (which will open in your app) definition in the manifest file.

<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />

The <category android:name="android.intent.category.DEFAULT" /> is optional and is only used to consume default intents.

Swayam
  • 16,294
  • 14
  • 64
  • 102
  • also thank you, how I can now commit url as parameter for my app ? My app dooes something with this url. thanks in advance ! – Akin Unknown Dec 17 '16 at 13:37
  • When your activity is started, you will get the URL that started this intent in the data of the Intent. – Swayam Dec 17 '16 at 14:56
  • Let me know if you want me to elaborate on that, if you still haven't been able to figure out the solution. – Swayam Dec 17 '16 at 14:57