Can anybody please guide me regarding how to launch my android application from the android browser?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Xamarin port of Felix's answer
In your
MainActivity
, add this (docs: Android.App.IntentFilterAttribute Class):Xamarin will add following in the
AndroidManifest.xml
for you:And in order to get params (I tested in OnCreate of MainActivity):
As far as I know, above can be added in any activity, not only MainActivity
Please note if your icon is disappear from android launcher when you implement this feature, than you have to split intent-filter.
Use an
<intent-filter>
with a<data>
element. For example, to handle all links to twitter.com, you'd put this inside your<activity>
in yourAndroidManifest.xml
:Then, when the user clicks on a link to twitter in the browser, they will be asked what application to use in order to complete the action: the browser or your application.
Of course, if you want to provide tight integration between your website and your app, you can define your own scheme:
Then, in your web app you can put links like:
And when the user clicks it, your app will be launched automatically (because it will probably be the only one that can handle
my.special.scheme://
type of uris). The only downside to this is that if the user doesn't have the app installed, they'll get a nasty error. And I'm not sure there's any way to check.Edit: To answer your question, you can use
getIntent().getData()
which returns aUri
object. You can then useUri.*
methods to extract the data you need. For example, let's say the user clicked on a link tohttp://twitter.com/status/1234
:You can do the above anywhere in your
Activity
, but you're probably going to want to do it inonCreate()
. You can also useparams.size()
to get the number of path segments in theUri
. Look to javadoc or the android developer website for otherUri
methods you can use to extract specific parts.Look @JRuns answer in here. The idea is to create html with your custom scheme and upload it somewhere. Then if you click on your custom link on your html-file, you will be redirected to your app. I used this article for android. But dont forget to set full name
Name = "MyApp.Mobile.Droid.MainActivity"
attribute to your target activity.In my case I had to set two categories for the
<intent-filter>
and then it worked:All above answers didn't work for me with
CHROME
as of 28 Jan 2014my App launched properly from http://example.com/someresource/ links from apps like hangouts, gmail etc but not from within chrome browser.
to solve this, so that it launches properly from CHROME you have to set intent filter like this
note the
pathPrefix
elementyour app will now appear inside activity picker whenever user requests http://example.com/someresource/ pattern from chrome browser by clicking a link from google search results or any other website