2

I ran into an issue in my Android Application where whenever I open my app through a dynamic link shared on Whatsapp, it will open in the same Whatsapp Application. I can see by going to the recent task that there is only one Application in a recent task which is Whatsapp and I can see my application inside it.

If I open my app from launcher icon then it will also create a new Application and there will be two application in recent tasks. My Splashscreen looks like this -

<activity
            android:name=".SplashScreen"
            android:screenOrientation="portrait"
            android:theme="@style/SplashTheme"
            android:windowSoftInputMode="stateAlwaysHidden">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</activity>
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Aman Verma
  • 3,155
  • 7
  • 30
  • 60

2 Answers2

2

You should added attribute in your activity

android:launchMode="singleTask"
Onix
  • 662
  • 3
  • 10
0

In general it is better to use a dedicated Activity for sharing from other applications. Another app should not launch your main (root) Activity to share, it should launch a different Activity. That Activity can then launch your main (root) Activity in a new task (if necessary). You need to consider the user's behaviour and make sure that you don't confuse the user with multiple tasks.

David Wasser
  • 93,459
  • 16
  • 209
  • 274