0

I am noticing a weird behavior in my app and not sure what is causing it or where to look for or where to start investigating.

So my main activity calls another activity sign in activity. My sign in activity has 2 layouts say layout A and layout B. As soon as I launch the app, layout A gets displayed and when I click on a button on layout A is hidden and layout B is displayed.

Sideloading the app:

During sideload, if I am on layout B and go to the background and come back to the app, the app still launched layout B and I noticed that onStart method gets called on SignIn Activity.

Downloading from HockeyApp or PlayStore:

On downloaded app, if I am on layout B and go to the background and comeback, the app displays layout A i.e. it doesn't maintain the state and goes through entire activity lifecycle again starting from onCreate. However if I force stop the app manually and try the same scenario, then it will behave like a sideloaded app i.e. it maintains the app state after coming from background.

Am not sure what is causing this behavior. Has anyone experienced such behavior before?

Adding the logic around both the activities from AndroidManifest file.

<activity
   android:name=".MainActivity"
   android:screenOrientation="portrait"
   android:windowSoftInputMode="adjustNothing"
   android:launchMode="singleTop"
   android:exported="true">
   <intent-filter>
      <action android:name="android.intent.action.MAIN" />

         <category android:name="android.intent.category.LAUNCHER" />
   </intent-filter>
   <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:scheme="test-app" />
          <data android:host="loc" />
   </intent-filter>
   <intent-filter android:autoVerify="true">
      <action android:name="android.intent.action.VIEW" />
      <category android:name="android.intent.category.DEFAULT" />
      <category android:name="android.intent.category.BROWSABLE" />
          <data android:scheme="https" />
          <data android:scheme="http" />
          <data android:host="*" />
          <data android:pathPattern="/.*/apps/test.*" />
    </intent-filter>
 </activity>
 <activity
    android:name=".SignInActivity"
    android:screenOrientation="portrait"
    android:windowSoftInputMode="adjustPan" />
tech_human
  • 6,592
  • 16
  • 65
  • 107
  • I have seen similar issue but don't have a specific answer. Anyway, play store / hockey etc. launch your app with the `Intent` returned from `PackageManager` `getLaunchIntentForPackage()` while the launcher apps usually use slightly different `Intent`s. Look for how you're navigating between activities in your app. – laalto Jun 21 '19 at 21:17
  • Hmm.. I doubt it has anything to do with how I am calling/navigating to Sign In activity. Coz in the case of when app is downloaded, all the activity life cycle starts again from the beginning i.e. MainActivity's onCreate is getting called, then onStart, onResume and so on and then it executes SignIn Activity's onCreate. I am trying to understanding why would the life cycle start again for the Main Activity – tech_human Jun 21 '19 at 21:53
  • I found this post - https://stackoverflow.com/questions/19545889/app-restarts-rather-than-resumes and the fix mentioned there helped resolve my issue – tech_human Jun 21 '19 at 22:46

0 Answers0