Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): prevent showing base activity #13889

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public abstract class TiApplication extends Application implements KrollApplicat
private static final String PROPERTY_DEFAULT_UNIT = "ti.ui.defaultunit";
private static final String PROPERTY_USE_LEGACY_WINDOW = "ti.android.useLegacyWindow";
private static long mainThreadId = 0;
private static boolean isDevelopment = false;

protected static TiApplication tiApp = null;

Expand Down Expand Up @@ -161,7 +162,6 @@ public TiApplication()
tiApp = this;

mainThreadId = Looper.getMainLooper().getThread().getId();

modules = new HashMap<>();
TiMessenger.getMessenger(); // initialize message queue for main thread
}
Expand Down Expand Up @@ -190,6 +190,24 @@ public static boolean firstOnActivityStack()
public static void addToActivityStack(Activity activity)
{
if (activity != null) {
if (!isDevelopment && activityStack.size() > 0) {
// only in production builds:
// remove root activity if another activity is opened
WeakReference<Activity> activityRef;
Activity currentActivity;
activityRef = activityStack.get(0);

if (activityRef.get() instanceof TiRootActivity) {
activityStack.remove(activityRef);
if (activityRef != null) {
currentActivity = activityRef.get();
if (currentActivity != null && !currentActivity.isFinishing()) {
currentActivity.finish();
}
}
}
}

activityStack.add(new WeakReference<>(activity));
}
}
Expand Down Expand Up @@ -345,6 +363,7 @@ public void onCreate()
{
super.onCreate();
Log.d(TAG, "Application onCreate", Log.DEBUG_MODE);
isDevelopment = !TiApplication.getInstance().getDeployType().equals(TiApplication.DEPLOY_TYPE_PRODUCTION);

// handle uncaught java exceptions
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
Expand Down
Loading