AndroidManifest.xml
文件
<activity
android:name=".activity.LaunchActivity"
android:autoVerify="true"
android:configChanges="orientation|keyboardHidden|screenSize|screenLayout"
android:label="@string/app_name"
android:noHistory="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="subdomain1.domain.ext"
android:path="/path1/subpath1/.*"
android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="subdomain1.domain.ext"
android:pathPattern="/path2/subpath2/..*"
android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="subdomain2.subdomain1.domain.ext"
android:pathPattern="^..*"
android:scheme="https" />
</intent-filter>
</activity>
<activity
android:name=".activity.LoginActivity"
android:configChanges="orientation|keyboardHidden|screenSize|screenLayout"
android:label="@string/app_name" />
<activity
android:name=".activity.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize|screenLayout"
android:label="@string/app_name" />
我想在两个域中使用Android应用程序链接,
-
-
子域2.subdomain1。领域提取
subdomain1.domain.ext/.well-known/assetlinks.json
subdomain2.subdomain1.domain.ext/.well-known/assetlinks.json
但在使用Android Studio安装应用程序时,
一、
到apache服务器的
.
请注意,我使用的是release build变体,它使用的密钥库文件与在assetlinks中生成SHA256指纹时使用的密钥库文件相同。json。
当我使用链接进行测试时,例如
https://subdomain1.domain.ext/path1/subpath1/
https://subdomain2.subdomain1.domain.ext/path2
只有较低的一个启动应用程序,前者只是在浏览器中打开。
问题1
在具有相同活动的不同主机上打开两个路径/链接
? 在我的情况下,我如何使第一个链接也打开应用程序?
. 我想
限制在应用程序中打开某些链接
android:pathPattern="^(?!foo|bar)..*$"
排除以foo和bar开头但允许其他路径的链接路径。
example.com in web browser
example.com/test in web browser
example.com/test/temp in web browser
example.com/{anything else} in the app
我阅读了其他stackoverflow帖子:
Android Deep linking omit certain url
问题3
. 它是
强制性的
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
期待您的帮助。Android团队不允许排除路径似乎太愚蠢了,他们应该从苹果的服务器端文件中学习,该文件使用了一个简单的not子句。
public class LaunchActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splashscreen);
Intent intent = getIntent();
if (intent != null) {
Uri target = intent.getData();
if (target != null && target.isHierarchical()) {
String goal = intent.getDataString();
List<String> params = target.getPathSegments();
Log.d(TAG, "app uri : " + goal);
Log.d(TAG, "app link : " + target.toString());
Log.d(TAG, "path segments : " + params);
if (target.toString().startsWith(MON_DOM)) {
if (searchString(AppLinksUtil.TARGET_URLS, target.toString())) {
Log.d(TAG, "Open TARGET Link in APP");
} else {
Log.d(TAG, "Open Excluded Link in Browser");
openLinkInChrome(LaunchActivity.this, goal);
finish();
}
} else if (target.toString().startsWith(ENQ_DOM)) {
Log.d(TAG, "Exclude List : " + AppLinksUtil.ENQ_EXCLUDE_URLS);
if (searchString(AppLinksUtil.EXCLUDE_URLS, target.toString())) {
Log.d(TAG, "Open Excluded Link in Browser");
openLinkInChrome(LaunchActivity.this, goal);
finish();
} else {
Log.d(TAG, "Open Link in APP");
}
}
}
} else {
Log.d(TAG, "no intent");
}
appFlow();
}
...
public void openLinkInChrome(final Activity activity, String link) {
Log.d(TAG, "Opening " + link + " in web browser");
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(link));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setPackage("com.android.chrome");
try {
activity.startActivity(intent);
} catch (ActivityNotFoundException ex) {
intent.setPackage(null);
activity.startActivity(intent);
}
}
public static boolean searchString(String[] arr, String targetValue) {
for (String s : arr) {
if (targetValue.startsWith(s))
return true;
}
return false;
}
}