Skip to content

Commit

Permalink
Fix Android stuck when opening from push notification (#1429)
Browse files Browse the repository at this point in the history
  • Loading branch information
enahum committed Feb 12, 2018
1 parent b9864bf commit 99cff03
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions android/app/src/main/java/com/mattermost/rnbeta/MainActivity.java
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;
}
}

0 comments on commit 99cff03

Please sign in to comment.