[MUSIC PLAYING]
SABS: Hi, everyone.
I am Sabs, and I'm an Android Developer Relations
Engineer at Google.
Sometimes you want to make it easy for users
to get to a specific place within your app.
For example, you want to show a subscription offer
or ask a user to update their profile or jump to the user's
cart in a shopping application.
You can use deep links to do this.
But what are deep links?
Well, deep links are a way to jump
into the middle of your app's navigation,
whether that's from an actual URL link or a pending
intent from a notification.
You can share these links outside your application
like in emails, messages, QR codes, social media,
and inside, shortcuts, notifications,
or between models in your app.
The user can click from anywhere,
and the links can be displayed to get
to that place within your app.
In this video, we will take a closer look
at different types of deep links.
We will go over how to set them up, test them, and share
deep link navigation best practices.
For a short intro about deep links,
check out part one, "What can you do with deep links?"
To quickly recap from part one, there
are different types of links you can
create in your Android app--
deep links, web links, and Android App Links.
Deep links are URIs with any scheme
that takes users directly to a specific place within your app.
Web links are deep links that use the HTTP and HTTPS schemes.
Android App Links are web links that are verified
to belong to your app only.
When a user clicks a link, a programmatic request
invokes a URI intent, and the Android system
tries to find the handler application that
can resolve that link.
To make sure that your app can be handler,
you need to do the three following steps--
add intent filters for incoming links,
read data from incoming intents, and test your deep links.
Let's explore step one.
For this step, you need to add intent filters
to your manifest file to drag users
to the right place in your app.
As shown in the following code snippet, in this example,
we added an intent filter that navigates users
to my map activity.
Let's explore elements and attribute
values of this intent filter.
I specify action VIEW so that the intent filter can
be reached from Google Search.
Include the DEFAULT category.
This allows your app to respond to implicit intents.
Without this, the activity can be
started only if the intent specifies your app component
name.
Include the BROWSABLE category.
It is required in order for the intent filter
to be accessible from a web browser.
Without it, clicking a link in the browser cannot result
to your app.
Add the data tag that represents the URI format that
results to the activity.
Once the Android system starts your activity through an intent
filter, you can use data provided by the intent
to determine any specifics about what needs to be shown.
This snippet shows how to retrieve data
from an intent using the data and action methods.
To test that our deep link results to the correct app
activity, you can use the Android Debug Bridge command.
The general syntax for testing an intent filter URI with ADB
is the following--
note that the package name can be skipped
from implicit intents but should be
provided for explicit intents.
Let's look at this example.
The command below tries to view an app
with a com.example.droidfood package associated
with the example droidfood URI.
The manifest declaration and intent
handler you set above define the connection between your app
and a deep link.
Now let's explore web links.
Web links are deep links that use the HTTP and HTTPS schemes.
They are implemented in the same way
except with the scheme of "http" or "https"
in your intent filter.
To validate yourself as the owner of a web link,
you will set up an Android App Link.
Android App Links are validated by the host domain of the link.
In our example, we had an app that
owns the droidfood.example.com domain
and has a corresponding web page.
When a user clicks on the validated Android App Link,
the app opens immediately if it's installed.
If the app is not installed and the user didn't set another app
to be the default handler, then the link
will be opened in a browser.
If the Android App Link doesn't pass the additional validation,
it will be opened in a browser.
In Android version less than 12, the disambiguation dialog
will appear.
To set up Android App Links, you need a few extra steps
beyond what you do for web links--
add autoVerify attribute to intent filters
and declare the association between your app and website.
Let's explore step four.
To enable Android App Link handling verification
for your app, add intent filters that
match the following format.
Make sure you explicitly set Android autoVerify to true,
provide HTTPS and HTTP schemes and the host.
In step five, declare the association
between your website and your intent filters
by hosting a digital assetlinks.json
file at the following location.
A digital assetlinks.json file must
be published on your website to indicate the Android apps that
are associated with the website and verify
the app's URL intents.
The following assetlinks.json file grants link-opening rights
to an Android app with the package droidfood.example.com.
The certificate fingerprint must match the release signature
used to sign your app.
If you're using Play App Signing,
make sure you're using the fingerprints from the signature
that Google uses to sign each of your releases, which
can be found in the Google Play Console.
You can add debug signature fingerprint, as well,
for testing.
The signature fingerprints should be in uppercase.
After you have confirmed the list of websites
to associate with your app and you
have confirmed that the hosted JSON file is valid,
install the app on your device.
Wait at least 20 seconds for the asynchronous verification
process to complete.
Use the following command to check
whether the system verified your app
and set the correct link handling policies.
Once you set up your deep links, follow these best practices
to improve users' experience.
The deep links should take users directly to the content
without any prompts, interserial pages, or logins.
Make sure that users can see the app content
even if they never previously opened the application.
If you need to prompt a user with a login screen
or onboarding flow, consider if you
can delay the prompt until a future
interaction when the user opens the app without a deep link.
Finally, your app should match users' expectations
for backward navigation after they enter
your app through a deep link.
Please check out the design guidance
described in the navigation with Back and Up
linked in the description below.
In this video, you learn how to implement
different types of deep links.
For more details, check out the understanding
the different types of links guide in the Android Developers
documentation link in the video description below.
If something doesn't work, watch our addressing pain points
and common mistakes video.
To see other content about deep links,
check out the deep links video series
crash course playlist in the Android Developers
channel on YouTube.
Thanks for watching.