Games  

How to Get a Mobile App Url

Android App Links are HTTP URLs that bring users straight to specific content in your Android app. Android App Links tin can bulldoze more traffic to your app, help y’all notice which app content is used most, and brand information technology easier for users to share and notice content in an installed app.

To add support for Android App Links:

  1. Create intent filters in your manifest.
  2. Add code to your app’south activities to handle incoming links.
  3. Acquaintance your app and your website with Digital Asset Links.

The App Links Assistant in Android Studio two.three and college simplifies the process in a pace-by-step wizard, as described beneath.

For more information about how app links work and the benefits they offer, read Handling Android App Links.

Add intent filters

The App Links Assistant in Android Studio can help you create intent filters in your manifest and map existing URLs from your website to activities in your app. The App Links Banana also adds template Coffee code in each corresponding action to handle the intent.

To add intent filters and URL handling, follow these steps:

  1. Select
    Tools > App Links Banana.
  2. Click
    Open URL Mapping Editor
    and then click
    Add


    at the bottom of the
    URL Mapping
    list to add a new URL mapping.
  3. Add details for the new URL mapping:
    The App Links Assistant walks you through basic URL mapping

    Effigy 1.
    Add basic details about your site’southward link structure to map URLs to activities in your app.

    1. Enter your website’s URL in the
      Host
      field.
    2. Add a
      path,
      pathPrefix, or
      pathPattern
      for the URLs you want to map. For example, if you lot accept a recipe-sharing app, with all the recipes available in the aforementioned activity, and your corresponding website’southward recipes are all in the aforementioned
      /recipe
      directory, employ
      pathPrefix
      and enter
      /recipe.
      This way, the URL
      http://www.recipe-app.com/recipe/grilled-potato-salad
      maps to the activity you select in the following step.
    3. Select the
      Activity
      the URLs should have users to.
    4. Click
      OK.
  4. The App Links Assistant adds intent filters based on your URL mapping to the
    AndroidManifest.xml
    file, and highlights it in the
    Preview
    field. If you lot’d similar to make whatsoever changes, click
    Open up AndroidManifest.xml
    to edit the intent filter. (Learn more about intent filters in Android.)

    Note:
    To support more than links without updating your app, you should ascertain a URL mapping that supports URLs that you’ll add in the future. Too, recall to include a URL for your app home screen and so information technology’southward included in search results.

  5. To verify your URL mapping works properly, enter a URL in the
    Check URL Mapping
    field and click
    Check Mapping. If it’s working correctly, the success bulletin shows that the URL you entered maps to the activity y’all selected.
Popular:   One More Day Till My Birthday

Handle incoming links

In one case y’all’ve verified that your URL mapping is working correctly, add logic to handle the intent y’all created.

  1. Click
    Select Activity
    from the App Links Assistant.
  2. Select an activity from the list and click
    Insert Code.

The App Links Assistant adds code to your activity’due south Java file, similar to the post-obit ( Please note: Currently the App Links Assistant does not back up Kotlin so you lot will need to add this lawmaking manually):

Kotlin

override fun onCreate(savedInstanceState: Package?) {     super.onCreate(savedInstanceState)      val appLinkIntent = intent     val appLinkAction = appLinkIntent.action     val appLinkData = appLinkIntent.data  }
          

Java

// Attention: This was auto-generated to handle app links. Intent appLinkIntent = getIntent(); String appLinkAction = appLinkIntent.getAction(); Uri appLinkData = appLinkIntent.getData();
          

However, this code isn’t consummate on its own. Y’all must now accept an activeness based on the URI in
appLinkData, such as display the corresponding content. For example, for the recipe-sharing app, your code might look similar the following sample:

Kotlin

override fun onCreate(savedInstanceState: Bundle?) {     super.onCreate(savedInstanceState)     ...     handleIntent(intent) }  override fun onNewIntent(intent: Intent) {     super.onNewIntent(intent)     handleIntent(intent) }  private fun handleIntent(intent: Intent) {     val appLinkAction = intent.action     val appLinkData: Uri? = intent.data     if (Intent.ACTION_VIEW == appLinkAction) {         appLinkData?.lastPathSegment?.also { recipeId ->             Uri.parse("content://com.recipe_app/recipe/")                     .buildUpon()                     .appendPath(recipeId)                     .build().also { appData ->                         showRecipe(appData)                     }         }     } }
          

Java

protected void onCreate(Package savedInstanceState) {   super.onCreate(savedInstanceState);   ...   handleIntent(getIntent()); }  protected void onNewIntent(Intent intent) {   super.onNewIntent(intent);   handleIntent(intent); }  private void handleIntent(Intent intent) {     String appLinkAction = intent.getAction();     Uri appLinkData = intent.getData();     if (Intent.ACTION_VIEW.equals(appLinkAction) && appLinkData != nix){         String recipeId = appLinkData.getLastPathSegment();         Uri appData = Uri.parse("content://com.recipe_app/recipe/").buildUpon()             .appendPath(recipeId).build();         showRecipe(appData);     } }
          

Acquaintance your app with your website

After setting upwards URL support for your app, the App Links Assistant generates a Digital Asset Links file y’all can use to acquaintance your website with your app.

Popular:   How to Leave Squad in Mobile Legends

As an alternative to using the Digital Asset Links file, you can associate your site and app in Search Panel.

To associate your app and your website using the App Links Banana, click
Open Digital Asset Links File Generator
from the App Links Assistant and follow these steps:

The App Links Assistant walks you through basic URL mapping

Figure 2.
Enter details about your site and app to generate a Digital Asset Links file.

  1. Enter your
    Site domain
    and your
    Awarding ID.
  2. To include back up in your Digital Asset Links file for Smart Lock for Passwords, select
    Support sharing credentials between the app and the website
    and enter your site’s login URL. This adds the following string to your Digital Nugget Links file declaring that your app and website share sign-in credentials:
    delegate_permission/common.get_login_creds. Larn more well-nigh supporting Smart Lock for Passwords in your app.
  3. Specify the signing config or select a keystore file. Make certain y’all select the correct config or keystore file for either the release build or debug build of your app. If you want to set up your production build, use the release config. If you desire to examination your build, utilise the debug config.
  4. Click
    Generate Digital Asset Links file.
  5. In one case Android Studio generates the file, click
    Save file
    to download it.
  6. Upload the
    assetlinks.json
    file to your site, with read-access for anybody, at
    https://<yoursite>/.well-known/assetlinks.json.

    Important:
    The system verifies the Digital Nugget Links file via the encrypted HTTPS protocol. Make sure that the
    assetlinks.json
    file is accessible over an HTTPS connection, regardless of whether your app’s intent filter includes
    https.

  7. Click
    Link and Verify
    to confirm that yous’ve uploaded the correct Digital Asset Links file to the correct location.
Popular:   Hipsters of the Coast Mtg Arena Tracker

Acquire more than about associating your website with your app through the Digital Nugget Links file in Declare Website Associations.

Test your App Links

To verify that your links open up the right activity, follow these steps:

  1. Click
    Exam App Links
    in the App Links Banana.
  2. Enter the URL you lot want to test in the
    URL
    field, for example,
    http://recipe-app.com/recipe/grilled-irish potato-salad.
  3. Figure iii.
    The App Links Assistant displays a success message and opens your app to the specified content when the URL you lot’re testing successfully maps to an activity in your app.

  4. Click
    Run Exam.
  5. If the URL mapping isn’t gear up properly or doesn’t be, an error message appears under the URL in the
    Test App Links
    window. If the URL mapping exists, Android Studio launches your app in the device or emulator at the specified activity without showing the disambiguation dialog (app “chooser”), and shows a success bulletin in the
    App Link Testing
    window. If Android Studio can’t successfully launch the app, an mistake bulletin appears in Android Studio’due south
    Run
    window.

To test Android App Links through the App Links Assistant, yous must have a device connected or a virtual device available running Android vi.0 (API level 23) or higher. For more than information, see how to connect a device or create an AVD.

Source: https://developer.android.com/studio/write/app-link-indexing