我正在实现Android中的深度链接,我想要做的是当用户点击链接时,将其重定向到应用程序,并且这已经可以工作,但我还希望用户能够看到我在链接中传递的一些值。
例如:我的链接是:https://examplelink.com/123456789。应用程序需要获取123456789代码。
我该怎么做呢?
注意:我已经在清单文件中添加了以下内容:
感谢您的帮助。
例如:我的链接是:https://examplelink.com/123456789。应用程序需要获取123456789代码。
我该怎么做呢?
注意:我已经在清单文件中添加了以下内容:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sendsharedlink">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:label="@string/app_name">
<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="https"
android:host="examplelink.com" />
</intent-filter>
</activity>
</application>
我通过以下方式解决了问题:
Intent intent = getIntent();
String action = intent.getAction();
Uri data = intent.getData();
String[] link = data.toString().split("/");
txt.setText(link[3]);
感谢您的帮助。