gpt4 book ai didi

android - 从深层链接检测打开的应用程序

转载 作者:行者123 更新时间:2023-11-30 00:19:59 24 4
gpt4 key购买 nike

我正在使用从深层链接到我的应用程序。如何检测我的应用程序是通过深层链接或应用程序图标打开的?

最佳答案

将您要在深层链接中使用的 URL 放入您的 manifest.xml 过滤器中。

<activity
android:name="com.example.android.GizmosActivity"
android:label="@string/title_gizmos" >
<intent-filter android:label="@string/filter_view_http_gizmos">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
<data android:scheme="http"
android:host="www.example.com"
android:pathPrefix="/gizmos" />
<!-- note that the leading "/" is required for pathPrefix-->
</intent-filter>
<intent-filter android:label="@string/filter_view_example_gizmos">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "example://gizmos” -->
<data android:scheme="example"
android:host="gizmos" />
</intent-filter>
</activity>

在您的 Activity 中,您可以检查如下数据:

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

Intent intent = getIntent();
String action = intent.getAction();
// using action u can detect
Uri data = intent.getData();
}

关于android - 从深层链接检测打开的应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46503545/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com