简体   繁体   中英

Opening my app by clicking on an external link?

Basically I want my app to show up in the list of the apps that pop up when you click on a link on android. Once the user chooses my app to open the link, I want it to be set as the content of a EditText. Any ideas of how I may do that?

Should help

https://developer.android.com/training/app-links/deep-linking

Register intent filter inside activity in manifest. This is small example

<intent-filter>
<data android:scheme="https" android:host="www.example.com" />
<data android:scheme="app" android:host="open.my.app" />
</intent-filter>

Check out this as Android documentation says:

To enable Google to crawl your app content and allow users to enter your app from search results, you must add intent filters for the relevant activities in your app manifest. These intent filters allow deep linking to the content in any of your activities. For example, the user might click on a deep link to view a page within a shopping app that describes a product offering that the user is searching for.

To do this you need to add an intent filter in your Manifest with action, data and category attributes:

<activity
android:name="com.example.android.GizmosActivity"
android:label="@string/title_gizmos" >
<intent-filter android:label="@string/filter_title_viewgizmos">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
    <data android:scheme="http"
          android:host="www.example.com"
          android:pathPrefix="/gizmos" />
    <!-- note that the leading "/" is required for pathPrefix-->
    <!-- Accepts URIs that begin with "example://gizmos” -->
    <data android:scheme="example"
          android:host="gizmos" />

You can read more about deep linking in developers.android

Hope this may help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM