正在尝试添加深度链接我的Android应用程序



我的应用程序运行良好,但每当我在清单中添加深度链接代码时,我的应用午餐图标就会消失,这就是我的清单文件

<activity
    android:name=".login.LoginActivity"
    android:screenOrientation="portrait">
    <intent-filter>
        <category android:name="android.intent.category.LAUNCHER" />
        <action android:name="android.intent.action.MAIN" />
        <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" />
        <data android:host="gizbo.ae" />
    </intent-filter>
</activity> 

当我添加这三条线进行深度链接时。应用程序图标启动图标从设备中消失。

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="https" />
<data android:host="gizbo.ae" />

甚至我删除了这两行

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE"/> 

同样的问题。

我只想让我的应用程序在谷歌搜索中可见,我正在关注这个链接

您必须使用多个意向过滤器标签:

  <activity
        android:name=".login.LoginActivity"
        android:screenOrientation="portrait">
        <intent-filter>
            <category android:name="android.intent.category.LAUNCHER" />
            <action android:name="android.intent.action.MAIN" />
        </intent-filter>
        <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="https" />
            <data android:host="gizbo.ae" />
        </intent-filter>
    </activity> 

您必须添加另一个活动来使用深度链接,然后启动登录活动并将数据传递给它。

因此,将活动声明如下:

 <activity
            android:name=".DeelinkActivity"
            android:screenOrientation="portrait"
            android:launchMode="singleTask"
            android:windowSoftInputMode="adjustResize|stateAlwaysHidden">
            <!-- URL scheme -->
            <intent-filter>
                <data android:host="gizbo.ae"
                    android:scheme="https" />
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
            </intent-filter>
            <!-- End URL scheme -->
  </activity>

然后在该活动的onCreate中,您可以调用登录活动,也可以从那里将数据传递给该活动。

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    Intent intent = getIntent();
    String action = intent.getAction();
    Uri data = intent.getData();
    //put code to pass data as extras and Start your login activity here
}

祝你好运。

相关内容

最新更新