【问题标题】:How can I create a Firebase Dynamic Link that will open an android instant app when clicked?如何创建一个 Firebase 动态链接,点击后会打开一个 android 即时应用程序?
【发布时间】:2021-06-06 14:46:08
【问题描述】:

所以我想创建一个链接,点击后会打开一个 android 即时应用程序。我已经创建了一个 Firebase 动态链接,但它会打开一个网络链接,而不是我的应用程序。 Here is the current behavior。我应该如何完成这项工作?

【问题讨论】:

    标签: android firebase firebase-dynamic-links


    【解决方案1】:

    在您的应用程序Manifest.xml 中,在Activity tag 中执行此操作,正好在Intent filter 中:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.application.test">
    
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    
    <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/Theme.Test">
        <activity android:name=".MainActivity">
    
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
    
                <!--  here put these lines : -->
    
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>
                
                <!-- here you write your dynamic link host and connection type -->
                <!-- I wrote Youtube so when a youtube link clicked, my app will open-->
                <data android:host="https://www.youtube.com" android:scheme="https"/>
    
                <!--  End -->
                
            </intent-filter>
        </activity>
    
    </application>
    
    </manifest>
    

    您可以使用这些行来获取点击的网址:

        String clickedUrl = getIntent().getDataString();
        webView.loadUrl(clickedUrl); // This webView just an example
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-29
      • 1970-01-01
      • 2016-04-14
      • 1970-01-01
      相关资源
      最近更新 更多