我有3个网址的设置意图过滤器
-> https://www.example.com ->打开活动A
<intent-filter>
<data android:scheme="Appname" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.example.com"
android:pathPrefix="/^/?$"
android:scheme="https" />
</intent-filter>-> https://www.example.com/internships或-> https://www.example.com/internships/打开活动B
<intent-filter android:label="Awign">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.example.com"
android:pathPattern="/internships^/?$"
android:scheme="https" />
</intent-filter>-> https://www.example.com/internships/{some_path_param} ->打开活动C
<intent-filter>
<data android:scheme="Appname" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.example.com"
android:pathPrefix="/^/?$"
android:scheme="https" />
</intent-filter>活动A和C如期打开,我如何才能实现活动B的预期结果?
另外,如何在chrome浏览器搜索中允许深度链接?例如,如果我在搜索结果中有这三个URL。我说的不是在地址栏中输入URL,而是搜索结果。正如在其他问题中提到的,在地址栏中键入结果无论如何都不会打开应用程序
发布于 2017-09-20 00:10:47
使用Branch's deep linking SDK,您应该能够通过添加$deeplink_path来简化此过程。这将允许您在不依赖正则表达式的情况下处理深度活动。
要进行此设置,您的清单只需包含以下内容:
<activity android:name="com.yourapp.your_activity">
<!-- App Link your activity to Branch links-->
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="yourapp-alternate.app.link" />
<data android:scheme="https" android:host="yourapp.app.link" />
</intent-filter>
</activity>然后,为了处理这个链接,你应该有这样的东西:
Branch branch = Branch.getInstance(getApplicationContext());
branch.initSession(new BranchReferralInitListener(){
@Override
public void onInitFinished(JSONObject referringParams, BranchError error) {
if (error == null) {
// params are the deep linked params associated with the link that the user clicked -> was re-directed to this app
// params will be empty if no data found
// ... insert custom logic here ...
} else {
Log.i("MyApp", error.getMessage());
}
}
}, this.getIntent().getData(), this);https://stackoverflow.com/questions/46295735
复制相似问题