My React Native Android app extension automatically closes whenever I navigate away from the app (go to homepage, switch apps). This behavior isn't present on iOS so I'm fairly certain it has something to do with the native Android code that I have.
Anyone who is familiar with developing in Android know how to solve this?
I've looked into savedInstanceState and I've included it in my onCreate method in my Activity file but I'm not quite sure if I'm doing it correctly and/or if I need to add something else.
import android.os.Bundle;
import android.view.WindowManager;
import com.facebook.react.ReactActivity;
public class ShareActivity extends ReactActivity {
@Override
protected String getMainComponentName() {
// this is the name AppRegistry will use to launch the Share View
return "Test";
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
}
The logcat displays something about a sessionId not being persisted and a win.mRemoveonExit=true but there isn't any documentation on these messages.
5205-5448/? E/CustomizedTextParser: getCustomizedText Rule is empty. mRuleMap={}
10935-11009/? E/PBSessionCacheImpl: sessionId[48094197094119864] not persisted.
1262-5461/? E/WindowManager: win=Window{8f906be u0 com.factrmobile/com.factrmobile.share.ShareActivity EXITING} destroySurfaces: appStopped=false win.mWindowRemovalAllowed=true win.mRemoveOnExit=true win.mViewVisibility=0 caller=com.android.server.wm.AppWindowToken.destroySurfaces:870 com.android.server.wm.AppWindowToken.destroySurfaces:851 com.android.server.wm.WindowState.onExitAnimationDone:5366 com.android.server.wm.-$$Lambda$01bPtngJg5AqEoOWfW3rWfV7MH4.accept:2 java.util.ArrayList.forEach:1262 com.android.server.wm.AppWindowToken.onAnimationFinished:2403 com.android.server.wm.AppWindowToken.setVisibility:551
5205-5205/? E/OverviewCommandHelper: No closing app
Any suggestions?
If anyone ever runs into this issue, check your AndroidManifest.xml and look where you define your activity. Make sure you do not have android:noHistory="true"
. Default value is false so leave it as is.