Trying to add Deep Linking my Android App

独自空忆成欢 提交于 2019-12-09 01:00:17

问题


My app is working fine but whenever i add deep link code in my manifest my app lunching icon disappears this is my manifest file

<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> 

When ever i add these three line for deep linking. App icon launching icon disappears from device.

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

even i removed these two lines

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

again same problem.

i just want to make my app visible in Google search and i am following this link


回答1:


You must use multiple intent-filter tags:

  <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> 



回答2:


You have to add another activity to use deep linking and then start your login activity and pass your data to that.

So declare the activity as below:

 <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>

and then in onCreate in that activity you can call the login activity also from there you can pass your data to that activity.

@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
}

Good luck.



来源:https://stackoverflow.com/questions/34610904/trying-to-add-deep-linking-my-android-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!