//这个方法就是我们deepLink的打开,只要传入要打开的链接就行
public static void openDeeplink(Context context, String deepLink) {
Intent intent = null;
if (null == context || TextUtils.isEmpty(deepLink))
return;
try {
intent = Intent.parseUri(deepLink, Intent.URI_INTENT_SCHEME);
} catch (URISyntaxException e) {
// Log.e(TAG, "URISyntaxException: " + e.getLocalizedMessage());
}
if (intent != null) {
intent.setComponent(null);
try {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
} catch (ActivityNotFoundException e) {
// Log.e(TAG, "ActivityNotFoundException: " + e.getLocalizedMessage());
}
}
}
Deeplink的打开方式
最新推荐文章于 2025-10-10 22:45:44 发布
该代码段展示了如何在Android中实现DeepLink的打开功能。通过`Intent.parseUri()`解析链接,并设置新任务标志以启动Activity。如果解析或启动过程中出现异常,日志会捕获并记录错误信息。
1180

被折叠的 条评论
为什么被折叠?



