@@ -13,13 +13,153 @@ When a clicked link or programmatic request invokes a web URI intent, the Androi
13
13
3 . Allow the user to select an app from a dialog.
14
14
15
15
<h4 >Android project instruction</h4 >
16
-
17
- Step 0: Create a android project and select language Java
18
- Step 1: Create 3 Activity
16
+ <br >Step 0: Create a android project and select language Java
17
+ <br >Step 1: Create 3 Activity
19
18
<br >- MainActivity
20
19
<br >- DemoLink2Activity
21
20
<br >- DemoLink3Activity
22
- Step 2:
21
+ <br >Step 2: Add intent-filter in AndroidManifest.xml in luncher activity area
22
+ <br >
23
+ <? xml version="1.0" encoding="utf-8"?>
24
+ <manifest xmlns: android ="http://schemas.android.com/apk/res/android "
25
+ package="com.bo.deeplinkdemo">
26
+
27
+ <application
28
+ android:allowBackup="true"
29
+ android:icon="@mipmap/ic_launcher"
30
+ android:label="@string/app_name"
31
+ android:roundIcon="@mipmap/ic_launcher_round"
32
+ android:supportsRtl="true"
33
+ android:theme="@style/AppTheme">
34
+ <activity android:name=".MainActivity">
35
+ <intent-filter>
36
+ <action android:name="android.intent.action.MAIN" />
37
+
38
+ <category android:name="android.intent.category.LAUNCHER" />
39
+ </intent-filter>
40
+
41
+ <!--AppLink-->
42
+ <intent-filter>
43
+ <action android:name="android.intent.action.VIEW" />
44
+
45
+ <category android:name="android.intent.category.DEFAULT" />
46
+ <category android:name="android.intent.category.BROWSABLE" />
47
+ <!--https://www.pexels.com-->
48
+ <data
49
+ android:host="www.pexels.com"
50
+ android:pathPattern="/@md-emran-hossain-emran-11822"
51
+ android:scheme="https" />
52
+
53
+ </intent-filter>
54
+
55
+ <!--DeepLink-->
56
+ <intent-filter>
57
+ <action android:name="android.intent.action.VIEW" />
58
+
59
+ <category android:name="android.intent.category.DEFAULT" />
60
+ <category android:name="android.intent.category.BROWSABLE" />
61
+ <!--https://www.pexels.com-->
62
+ <data
63
+ android:host="yrhost.com"
64
+ android:pathPattern="/target_activity"
65
+ android:scheme="uapp" />
66
+
67
+ </intent-filter>
68
+
69
+
70
+ <!--DeepLink-->
71
+ <intent-filter>
72
+ <action android:name="android.intent.action.VIEW" />
73
+
74
+ <category android:name="android.intent.category.DEFAULT" />
75
+ <category android:name="android.intent.category.BROWSABLE" />
76
+ <!--https://www.pexels.com-->
77
+ <data
78
+ android:host="yrhost.com"
79
+ android:pathPattern="/target_another_activity"
80
+ android:scheme="uapp" />
81
+
82
+ </intent-filter>
83
+
84
+ </activity>
85
+ <activity android:name=".DemoLink1Activity" />
86
+
87
+ <activity
88
+ android:name=".DemoLink2Activity"
89
+ android:label="@string/title_activity_demo_link2"
90
+ android:theme="@style/AppTheme.NoActionBar" />
91
+
92
+ <activity
93
+ android:name=".DemoLink3Activity"
94
+ android:label="@string/title_activity_demo_link3"/>
95
+ </application>
96
+
97
+ </manifest >
98
+ <br >
99
+ 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 a browser cannot resolve to your app.
100
+ Also 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.
101
+ <br >Strp 3: Read data from incoming intents (<a herf =" https://developer.android.com/training/app-links/deep-linking#java " target =" _blank " >More</a >)
102
+ <br >
103
+ <br >package com.bo.deeplinkdemo;
104
+ <br >
105
+ <br >import android.content.Context;
106
+ <br >import android.content.Intent;
107
+ <br >import android.support.v7.app.AppCompatActivity;
108
+ <br >import android.os.Bundle;
109
+ <br >import android.util.Log;
110
+ <br >
111
+ <br >public class MainActivity extends AppCompatActivity {
112
+
113
+ private Context mContext;
114
+
115
+ @Override
116
+ protected void onCreate(Bundle savedInstanceState) {
117
+ super.onCreate(savedInstanceState);
118
+ setContentView(R.layout.activity_main);
119
+ mContext = this;
120
+ deepLinkSwitcher();
121
+ }
122
+
123
+ private void deepLinkSwitcher() {
124
+ Intent intent = getIntent();
125
+ if (intent != null && intent.getData() != null) {
126
+ String intentData = intent.getData().toString();
127
+ Log.d("deepData", "" + intentData);
128
+ if (intentData != null && !intentData.isEmpty()) {
129
+
130
+ /*
131
+ Here
132
+ SCHEME = https
133
+ HOST = www.pexels.com
134
+ PATH PATTERN = /@md-emran-hossain-emran-11822
135
+ * */
136
+ Intent intObj=null;
137
+ if (intentData.equalsIgnoreCase("https://www.pexels.com/@md-emran-hossain-emran-11822")) {
138
+ intObj = new Intent(mContext , DemoLink1Activity.class);
139
+ }
140
+
141
+ /*
142
+ Here
143
+ SCHEME = uapp
144
+ HOST = yrhost.com
145
+ PATH PATTERN = /target_activity
146
+ * */
147
+ else if(intentData.equalsIgnoreCase("uapp://yrhost.com/target_activity")){
148
+ intObj = new Intent(mContext , DemoLink2Activity.class);
149
+ }
150
+ else if(intentData.equalsIgnoreCase("uapp://yrhost.com/target_another_activity")){
151
+ intObj = new Intent(mContext , DemoLink3Activity.class);
152
+ }
153
+
154
+ if(intObj!=null)
155
+ startActivity(intObj);
156
+ }
157
+ }
158
+ }//end function
159
+ <br >}
160
+
161
+
162
+
23
163
_________________________________________________
24
164
<h4 >Backend setup</h >
25
165
<br >For example we use 3 web Url
0 commit comments