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

Closed
wants to merge 17 commits into from
Closed
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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this hack might be a symthome of not using the best possible solution. According to both Apple and Google, apps should have the same core-functionality between dev and prod

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only need it for Liveview as that needs the first activity not to be closed to restart the app. But we don't have a way to check for Liveview, that's why I've used dev/prod to do the check

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, then @prashantsaini1 will know what to do. It's still odd to have this check, but looking at Liveview it may make sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it works without it but Liveview will look a bit different as you'll see the home screen and then it will launch again. I don't like the dev/prod difference either 😄 Let's see what Prashant will find 👍

// 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