Starting app only if its not currently running

后端 未结 11 1703
我寻月下人不归
我寻月下人不归 2020-12-02 23:07

I am sending push notification to users which when clicking on it opens the app.

My problem is that when the app is already open, clicking on the notification start

11条回答
  •  隐瞒了意图╮
    2020-12-02 23:51

    Use Splash as Fragment instead of Activity. Keep Splash fragment(7 seconds), replace the same with the desired one(landing page).

    Add launchMode="singleTask" to the manifest.

    As already stated by Rahul, onNewIntent() get called if application is already running else onCreate()

    @Override
    protected void onNewIntent(Intent intent) 
    {   
        super.onNewIntent(intent);
    }
    

    OR

    Go with David's answer, seems promising.

提交回复
热议问题