I developed a deep link app. The intent data remains, when I close the app by the back button and restart from the task After launching from deep link.
Manifest:
<application
<activity
android:name=".MainActivity"
android:label="@string/appName"
android:launchMode="singleTask">
<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:host="news"
android:scheme="example" />
</intent-filter>
</activity>
<activity
android:name=".NextActivity" />
</application>
MainActivity:
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (intent.action == Intent.ACTION_VIEW && Uri.parse(intent.data.toString()).host == "news") {
// Transition NextActivity
}
}
}
In case of startup after closing with the back button, the code of "Transition Next Activity" is passed many times.
I tried this but did not work.
intent.data = null
setIntent(intent)