How To Create Deep Links In Android Apps- Deep Linking Android Apps



Hii guys welcome back my new post in this post i will show you How to add deep link android app also Create Deep links to app Content so guys let's start 

What is deep link in Android

Deep link basically works inside android which any users can open their the app's home page from the website, by clicking on the link it can be redirected inside android app,

if i tell you in easy words, you can come inside any app by clicking on the link through the website,

Example Deep Link in Android

let me explain to you by example, if you have clicked the link of Facebook on a website, then you are automatically redirected to Facebook application, if Amazon link is there, then amazon app is opened when you click, because deep link Function is added inside these apps. 

Why is deep linking important

Deep linking is very important, because it helps the users to get inside the app from the webpage and can aslo be accessed from one app to another app by Deep link,

Deep link also consumes the user's time and secondly it can easily do multitasking work.

How to create deep link in android app

now let's see how we can add deep link function inside our android application with the help of programming.

there are two things you need to know before adding deep link function in android app

     1.if you are creating an android app, you have original source code android app, then  you can also add deep link function to it.

      2. and if you do not have the orignal source code of android app, you can also add the deep link function indise the application.

What is required for create deep link in android app

to add deep link to android application, you will need Android Studio, AIDE, and Html Code Editor,

i'm currently use Aide android application, i will add deep link function with help of Aide application,

Adding deep link in android app

Step-1

in the first step you have to import the source code of the android application into Aide application, you can also copy and import any android application project from github for testing.

don't worry for testing, i provide you a link to an android application project on my Github page.

Step-2

in step two you have to open the AndroidManifest.xml file of the application you imported inside the Aide, within this manifest file we are going to paste the code of deep link.

and you have to repeat the same process inside the Complied application, in its manifest file you have to paste the same deep link code.

Step-3

in step three you have to paste the code of deep link below the end point of intent-filter. in the image below you can see how i pasted 

i have added the url of my website inside this deep link code that anyone click this url like https://www.linuxndroid.com and /login then the application promt will open.

You have to copy the Deep link given below.

 <intent-filter android:label="@string/app_name">
       
<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="https"
             
android:host="www.linuxndroid.com"
             
android:pathPrefix="/login" />
       
<!-- note that the leading "/" is required for pathPrefix-->
   
</intent-filter>

Now in this image you can see how i have pasted the deep link code


Step-4

after pasting the deep link code into the AndroidManifest file, you need to do a simple Html coding, in that code you will to paste your web url,

the Html coding that we need is because Google chrome browser does not support direct links, so you can embed your url inside a button and you can embed it inside any text.

and you can host this Html file on any web server or you can also access it with google chrome browser by saving it to your sdcard, to access it from google chrome you have to type it file:///sdcard/yourhtmlfile  

You can copy my Html coding below for testing

 
<!DOCTYPE html>  
 <html>  
 <head>  
 <style>  
 h2 {text-align: center;}  
 p.ex1 {  
  font-size: 50px;  
 </style>  
 </head>  
 <body>  
 <p class="ex1">This Is Demo For Deep Link Android</p>  
 <a href="https://www.linuxndroid.com/login"><h2>Click Here</h2></a>  
 </html>

Step-5

after building the application and hosting the Html file, now let me show you that i click on the link and our application deep link prompt opens in front of us,

in the image below you can see how it is asking to open our application.


One More thing

as you have seen, after clicking on the link, our application is asking to open the user, you can also remove this prompt message if you want.

so that if the user clicks on the link, then he will automatically open the app and redirect without show prompt and asking message,

How to open app from link without asking user

to do this process you have to make small changes inside the earlier code. so what are the changes that we see in detail in this steps.

Step-1

for this, you have to paste the code of deep link inside the manifest file, you see a line in it <data android:scheme="https"  now you have to remove the https you see in it and type myapp for this, you copy and paste the code below.

 <intent-filter android:label="@string/filter_view_http_gizmos">
       
<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="myapp"
             
android:host="www.linuxndroid.com"
             
android:pathPrefix="/login" />
       
<!-- note that the leading "/" is required for pathPrefix-->
   
</intent-filter>

To improve you can see in the below image

Final Step

after editing in the manifest file, you also have to edit your Html coding file, in this also you have to remove https and type myapp or if you want, you can also use my code below.

now after this, you click on the link, your application will be opened without any prompt and ask message, you will automatically redirect in the application.

 
<!DOCTYPE html>  
 <html>  
 <head>  
 <style>  
 h2 {text-align: center;}  
 p.ex1 {  
  font-size: 50px;  
 </style>  
 </head>  
 <body>  
 <p class="ex1">This Is Demo For Deep Link Android</p>  
 <a href="myapp://www.linuxndroid.com/login"><h2>Click Here</h2></a>  
 </html>

and you can also see in the image below that you have used the correct code.


Conclusion


the conclusion of this post is how can open the android application through link by adding deep link function and how deep link works in android app, so i hope you like this post and please share this post and i will see you in the next post Thanks.


Post a Comment

0 Comments