Search code examples
androidandroid-activityfragmentandroid-deep-link

Is there any way to disable deep link on Fragment?


I implemented an app using NFC which has URL link. So, When NFC is on, the mobile detects URL and opens my app.

I made it happen like this:

<activity
    android:name=".view.main.MainActivity"
    android:launchMode="singleTop"
    android:screenOrientation="portrait">
    <intent-filter>
        <action android:name="android.nfc.action.NDEF_DISCOVERED" />
        <action android:name="android.nfc.action.TECH_DISCOVERED" />
        <!--<action android:name="android.intent.action.MAIN" />-->

        <!--<category android:name="android.intent.category.LAUNCHER" />-->
        <category android:name="android.intent.category.DEFAULT" />

        <data
            android:host="example.com"
            android:scheme="http" />
    </intent-filter>

    <meta-data
        android:name="android.nfc.action.TECH_DISCOVERED"
        android:resource="@xml/nfc_tech_filter" />
</activity>

However, the problem is, I have many activities and fragments. It works even while I use my application and It keeps open my application on each and every activities and fragments.

I don't want this behaviour. I want it detects URL just out of my application. How can I achieve this behaviour?


Solution

  • make it single task to avoid multiple opening of the activity

    android:launchMode="singleTask" 
    

    also read this doc maybe help you