Trying to add Deep Linking my Android App

前端 未结 2 1924
悲哀的现实
悲哀的现实 2021-01-06 11:50

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



        
相关标签:
2条回答
  • 2021-01-06 12:18

    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> 
    
    0 讨论(0)
  • 2021-01-06 12:28

    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.

    0 讨论(0)
提交回复
热议问题