配置scheme
注意:
一定要配置action否则无法跳转
一定要单独使用intent-filter,否则无效并且在入口文件中写入后导致app图标无法在桌面显示。
<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:scheme="app" android:host="test"/> </intent-filter>
判断scheme是否存在,在进行跳转
PackageManager packageManager = getPackageManager(); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("app://test")); List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0); boolean isValid = !activities.isEmpty(); if (isValid) { startActivity(intent); }