0

I have SplashActivity to show animation and init some data, after animation finishes I start MainActivity and call finish() for SplashActivity. When I am at MainActivity and press Home button, than open Play Market, found my app and press Open button, my app starts from SplashActivity. But when I open my app from recent or from icon in apps list it works OK.

Summing: How it is: SplashActivty->MainActivity->Home Button->Play Market->MyApp->Open Button->SplashActivity

How I need: SplashActivty->MainActivity->Home Button->Play Market->MyApp->Open Button->MainActivity

I guess that Play Market adds some special flags to intent when launching app, but this behavior is not acceptable for me, maybe someone had the same problem and can advice me some solution.

This is SplashActivity in AndroidManifest

<activity
    android:name=".activities.SplashActivity"
    android:screenOrientation="portrait"
    android:windowSoftInputMode="stateAlwaysHidden"
    android:theme="@style/SplashTheme"
    tools:replace="name">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

This is code to launch MainActivity

public void openMainActivity() {
    Intent intent = new Intent(this, MainActivity.class);
    startActivity(intent);
    overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
    finish();
}
Kewin Dousse
  • 3,880
  • 2
  • 25
  • 46
  • What if you again start your app from app icon will it start from splash or MainActivity? – Ashish Shukla Oct 21 '16 at 10:37
  • It depends who init app launch at first time, if first launch init Play Market and than open app using icon, app will be launched from SplashActivity, but if first launch were from icon, and then open app by icon, app will be launched from MainActivity – vchernyshov Oct 21 '16 at 11:32
  • You are seeing a long-standing Android bug. See my answer to this question: http://stackoverflow.com/a/16447508/769265 – David Wasser Oct 23 '16 at 21:02
  • 1
    Thank you @DavidWasser, your answer helps to fix my problem – vchernyshov Oct 24 '16 at 17:47

0 Answers0