-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Android stuck when opening from push notification (#1429)
- Loading branch information
Showing
1 changed file
with
25 additions
and
4 deletions.
There are no files selected for viewing
29 changes: 25 additions & 4 deletions
29
android/app/src/main/java/com/mattermost/rnbeta/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,31 @@ | ||
package com.mattermost.rnbeta; | ||
|
||
import android.os.Bundle; | ||
import android.support.annotation.Nullable; | ||
import com.reactnativenavigation.controllers.SplashActivity; | ||
|
||
public class MainActivity extends SplashActivity { | ||
@Override | ||
public int getSplashLayout() { | ||
return R.layout.launch_screen; | ||
} | ||
@Override | ||
protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
/** | ||
* Reference: https://stackoverflow.com/questions/7944338/resume-last-activity-when-launcher-icon-is-clicked | ||
* 1. Open app from launcher/appDrawer | ||
* 2. Go home | ||
* 3. Send notification and open | ||
* 4. It creates a new Activity and Destroys the old | ||
* 5. Causing an unnecessary app restart | ||
* 6. This solution short-circuits the restart | ||
*/ | ||
if (!isTaskRoot()) { | ||
finish(); | ||
return; | ||
} | ||
} | ||
|
||
@Override | ||
public int getSplashLayout() { | ||
return R.layout.launch_screen; | ||
} | ||
} |