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.
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
click me!
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
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.
Related
i need to launch my app when click on link that is received by sms or email.I mean, the person who receives the SMS simply taps on the link provided, and that launches the application.
Which ever Activity you want to open, when Link is clicked
Need to be use IntentFilter in Menifest like this
<activity
android:name=".interacting.InteractWithApps"
android:parentActivityName=".index.IndexActivity">
<intent-filter>
<data
android:host="www.domain.com"
android:scheme="http" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
You also need to define link schema and host
You should follow as per this link
TL;DR Can i use two actions and two categories in one intent-filter?
My app is made up of one activity and five fragments. I have an Intent Filter in this activity.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Today, I saw a lint message "App is not indexable by Google..." around the application tag in manifest file. So, I did some searching and came to know that you can use this to index your app through google search. If an android user browses web link "www.example.com/myapp" from chrome/systemBrowser, he will be taken to my app instead of web page. right?
Now, I have to add an ActionView to the activity. and, my intent-filter will become,
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" android:host="www.example.com" android:pathPrefix="/myapp" />
</intent-filter>
But, I have read that using two actions is not good. It is a Logical OR operation. Intent-Filter will match only one of them:
an intent with MAIN action and LAUNCHER Category
an intent with MAIN action and BROWSABLE Category
an intent with VIEW action and LAUNCHER Category
an intent with VIEW action and BROWSABLE Category
As i understand it, It should open app on device with first option, and when a user browses the browser with provided "www.example.com/myapp", it should use first and fourth option to open the app from link.
I have looked at this question, but i need to be sure with an example.
It is confusing. I might be entirely wrong, please guide me.
By the help of someone from SO Chat, I was told to use separate intent-filters
<activity
android:name=".activities.MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" android:host="www.example.com" android:pathPrefix="/prefix" />
</intent-filter>
</activity>
I wanted to register my launcher activity so it could be started by both clicking on icon and opening link with a custom scheme. I managed to make it work but am questioning is this correct way. This is the relevant part of my manifest:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />
<category android:name="android.intent.category.LAUNCHER" />
</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="my.sheme" />
</intent-filter>
This does work but I was wondering should I register both actions under same intent filter. I tried just moving tags from second filter to the first one but then my activity doesn't show icon on install. Is it possible to do it this way and I just made some small syntax error(or broke some undocumented order of declaration rule) or is my thinking completely wrong on this and there are deeper reasons why this doesn't work?
NOTE:I do set android:exported="true"but android.intent.action.MAIN works even without it because it becomes exported anyway if you use action.MAIN
As the Android documentation states:
When you want to handle multiple kinds of intents, but only in specific combinations of action, data, and category type, then you need to create multiple intent filters.
Otherwise you can group them into one intent-filter.
Although I have gone through related document on google for app indexing
https://developers.google.com/app-indexing/webmasters/details
But still have confusion that If I want to receive incoming data on launcher activity and from there If can take control and start relevant activity/fragment depending on some internal parsing over incoming url.
You have to declare the action, category and data in a separate <intent-filter> tag, not in the same one with launcher specs.
<activity>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</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="your.domain.com"
android:scheme="http" />
</intent-filter>
</activity>
Not quite sure if I understood what your asking, so please correct me if I'm not answering your question.
Only the activity (or activities) that you put the intent filter in will catch an intent and start. Therefore, if you only put the intent filter in one activity, only that activity will start, and not any of the others. You can put multiple intent filters in the same activity to catch multiple intents. You can also use the path segment of the url to send more information to your activity, and parse it in your activity.
Put the following in your manifest under the activity you want to launch (the path 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" android:host="www.yourwebsite.com" />
</intent-filter>
Use a url like http://www.yourwebsite.com/yourstring to open the app.
Then use getIntent().getData() to get the uri that started the activity. You can then parse the uri to get yourstring.
Add Following Intent filter to Activity you want to open via Deep linking in Manifest.
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Then As per Intent data you get in Activity you can perform your action, too.
I need an option say "Chat with this Contact" included in the options list when you click Contacts in Android and then select options.
Basically what I want to find out is if I can link my application feature say chat directly with the contacts menu in Android? Are there any examples for that?
I don't think we can do that. The options we see on pressing the hard option key ( or soft one on recent handsets) are generated from either xml or by programatically. They are not some kind of a global properties to be set (kind of like Blackberry apps). So, NO...
If you want to send user to your chatting/communication application, you can do that by registering the android.intent.action.SENDTO and/or android.intent.action.SEND intent filters with your activity.
Here's how I did it.
<activity
android:name=".EventCreaterActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="sms" />
<data android:scheme="smsto" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*" />
</intent-filter>
</activity>
If you set these intent filters appropriately, on clicking any contact user will get a prompt to chose between the default messaging application and your application which, I think, fairly serves your purpose.