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): fix restart activity #13394

Merged
merged 2 commits into from
Apr 13, 2022
Merged

Conversation

m1ga
Copy link
Contributor

@m1ga m1ga commented Apr 13, 2022

After this #13390 killing and resuming a empty Android app causes this error:

java.lang.IllegalStateException: System services not available to Activities before onCreate()
      at android.app.Activity.getSystemService(Activity.java:6871)
      at com.android.internal.policy.DecorContext.getSystemService(DecorContext.java:94)
      at android.content.Context.getSystemService(Context.java:3936)
      at android.view.ViewRootInsetsControllerHost.getInputMethodManager(ViewRootInsetsControllerHost.java:233)
      at android.view.ImeInsetsSourceConsumer.getImm(ImeInsetsSourceConsumer.java:164)
      at android.view.ImeInsetsSourceConsumer.onWindowFocusLost(ImeInsetsSourceConsumer.java:62)
      at android.view.InsetsController.onWindowFocusLost(InsetsController.java:1374)
      at android.view.ViewRootImpl.dispatchDetachedFromWindow(ViewRootImpl.java:5078)
      at android.view.ViewRootImpl.doDie(ViewRootImpl.java:8282)
      at android.view.ViewRootImpl.die(ViewRootImpl.java:8259)
      at android.view.WindowManagerGlobal.removeViewLocked(WindowManagerGlobal.java:500)
      at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:441)
      at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:196)
      at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:5512)
      at android.app.servertransaction.DestroyActivityItem.execute(DestroyActivityItem.java:47)
      at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
      at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
      at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2253)
      at android.os.Handler.dispatchMessage(Handler.java:106)
      at android.os.Looper.loopOnce(Looper.java:201)
      at android.os.Looper.loop(Looper.java:288)
      at android.app.ActivityThread.main(ActivityThread.java:7870)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

Test:

const win = Ti.UI.createWindow();
win.open();
  • start the app
  • kill it
  • swipe right to restart the old app

@drauggres
Copy link
Contributor

Yep, my bad.
But I don't like the name again, return value is not an application context. Maybe use something like getOriginalBaseContext or getInitialBaseContext?

@m1ga
Copy link
Contributor Author

m1ga commented Apr 13, 2022

then lets use getInitialBaseContext()

@hansemannn hansemannn merged commit 0205aa7 into tidev:master Apr 13, 2022
@m1ga m1ga deleted the fixBaseActivity branch April 22, 2022 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants