launcher activity market bug fixed

This commit is contained in:
Gavriil Sitnikov 2016-07-15 01:43:56 +03:00
parent dff8fd1703
commit b0dc24d554
1 changed files with 17 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package ru.touchin.roboswag.components.navigation.activities;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@ -35,9 +36,25 @@ public abstract class BaseActivity extends AppCompatActivity
return resumed;
}
protected boolean isLauncherActivity() {
return false;
}
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Possible work around for market launches. See http://code.google.com/p/android/issues/detail?id=2373
// for more details. Essentially, the market launches the main activity on top of other activities.
// we never want this to happen. Instead, we check if we are the root and if not, we finish.
if (isLauncherActivity() && !isTaskRoot()) {
final Intent intent = getIntent();
if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN.equals(intent.getAction())) {
finish();
return;
}
}
isCreatedSubject.onNext(true);
}