TWiStErRob / net.twisterrob.libraries

1 stars 0 forks source link

BaseApp.toastUser uses wrong context #37

Closed TWiStErRob closed 1 year ago

TWiStErRob commented 1 year ago
StrictMode policy violation: android.os.strictmode.IncorrectContextUseViolation: WindowManager should be accessed from Activity or other visual Context. Use an Activity or a Context created with Context#createWindowContext(int, Bundle), which are adjusted to the configuration and visual bounds of an area on screen.
    at android.os.StrictMode.onIncorrectContextUsed(StrictMode.java:2260)
    at android.app.ContextImpl.getSystemService(ContextImpl.java:2116)
    at android.content.ContextWrapper.getSystemService(ContextWrapper.java:900)
    at android.content.Context.getSystemService(Context.java:4158)
    at android.widget.ToastPresenter.<init>(ToastPresenter.java:104)
    at android.widget.Toast$TN.<init>(Toast.java:642)
    at android.widget.Toast.<init>(Toast.java:174)
    at android.widget.Toast.makeText(Toast.java:498)
    at android.widget.Toast.makeText(Toast.java:487)
    at net.twisterrob.android.app.BaseApp.doToastUser(BaseApp.java:236)
    at net.twisterrob.android.app.BaseApp.toastUser(BaseApp.java:230)
    at net.twisterrob.inventory.android.view.ChangeTypeListener$ImagedVariants$1.onResult(ChangeTypeListener.java:69)
    at net.twisterrob.android.utils.concurrent.ClosureAsyncTask.onResult(ClosureAsyncTask.java:23)
    at net.twisterrob.android.utils.concurrent.ClosureAsyncTask.onResult(ClosureAsyncTask.java:10)
    at net.twisterrob.android.utils.concurrent.SafeAsyncTask.onPostExecute(SafeAsyncTask.java:54)
    at net.twisterrob.android.utils.concurrent.SafeAsyncTask.onPostExecute(SafeAsyncTask.java:12)
    at android.os.AsyncTask.finish(AsyncTask.java:771)
    at android.os.AsyncTask.-$$Nest$mfinish(Unknown Source:0)
    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:788)
    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:7872)
    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:936)
Caused by: java.lang.IllegalAccessException: Tried to access visual service WindowManager from a non-visual Context:net.twisterrob.inventory.android.DebugApp@f41ce72
    at android.app.ContextImpl.getSystemService(ContextImpl.java:2115)
    at android.content.ContextWrapper.getSystemService(ContextWrapper.java:900) 
    at android.content.Context.getSystemService(Context.java:4158) 
    at android.widget.ToastPresenter.<init>(ToastPresenter.java:104) 
    at android.widget.Toast$TN.<init>(Toast.java:642) 
    at android.widget.Toast.<init>(Toast.java:174) 
    at android.widget.Toast.makeText(Toast.java:498) 
    at android.widget.Toast.makeText(Toast.java:487) 
    at net.twisterrob.android.app.BaseApp.doToastUser(BaseApp.java:236) 
    at net.twisterrob.android.app.BaseApp.toastUser(BaseApp.java:230) 
    at net.twisterrob.inventory.android.view.ChangeTypeListener$ImagedVariants$1.onResult(ChangeTypeListener.java:69) 
    at net.twisterrob.android.utils.concurrent.ClosureAsyncTask.onResult(ClosureAsyncTask.java:23) 
    at net.twisterrob.android.utils.concurrent.ClosureAsyncTask.onResult(ClosureAsyncTask.java:10) 
    at net.twisterrob.android.utils.concurrent.SafeAsyncTask.onPostExecute(SafeAsyncTask.java:54) 
    at net.twisterrob.android.utils.concurrent.SafeAsyncTask.onPostExecute(SafeAsyncTask.java:12) 
    at android.os.AsyncTask.finish(AsyncTask.java:771) 
    at android.os.AsyncTask.-$$Nest$mfinish(Unknown Source:0) 
    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:788) 
    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:7872) 
    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:936) 
StrictMode policy violation: android.os.strictmode.IncorrectContextUseViolation: The API:LayoutInflater needs a proper configuration. Use UI contexts such as an activity or a context created via createWindowContext(Display, int, Bundle) or  createConfigurationContext(Configuration) with a proper configuration.
    at android.os.StrictMode.onIncorrectContextUsed(StrictMode.java:2260)
    at android.os.StrictMode.assertConfigurationContext(StrictMode.java:2296)
    at android.view.LayoutInflater.<init>(LayoutInflater.java:260)
    at com.android.internal.policy.PhoneLayoutInflater.<init>(PhoneLayoutInflater.java:44)
    at android.app.SystemServiceRegistry$32.createService(SystemServiceRegistry.java:540)
    at android.app.SystemServiceRegistry$32.createService(SystemServiceRegistry.java:537)
    at android.app.SystemServiceRegistry$CachedServiceFetcher.getService(SystemServiceRegistry.java:1900)
    at android.app.SystemServiceRegistry.getSystemService(SystemServiceRegistry.java:1577)
    at android.app.ContextImpl.getSystemService(ContextImpl.java:2120)
    at android.content.ContextWrapper.getSystemService(ContextWrapper.java:900)
    at android.view.LayoutInflater.from(LayoutInflater.java:288)
    at android.widget.ToastPresenter.getTextToastView(ToastPresenter.java:66)
    at android.widget.Toast.makeText(Toast.java:503)
    at android.widget.Toast.makeText(Toast.java:487)
    at net.twisterrob.android.app.BaseApp.doToastUser(BaseApp.java:236)
    at net.twisterrob.android.app.BaseApp.toastUser(BaseApp.java:230)
    at net.twisterrob.inventory.android.view.ChangeTypeListener$ImagedVariants$1.onResult(ChangeTypeListener.java:69)
    at net.twisterrob.android.utils.concurrent.ClosureAsyncTask.onResult(ClosureAsyncTask.java:23)
    at net.twisterrob.android.utils.concurrent.ClosureAsyncTask.onResult(ClosureAsyncTask.java:10)
    at net.twisterrob.android.utils.concurrent.SafeAsyncTask.onPostExecute(SafeAsyncTask.java:54)
    at net.twisterrob.android.utils.concurrent.SafeAsyncTask.onPostExecute(SafeAsyncTask.java:12)
    at android.os.AsyncTask.finish(AsyncTask.java:771)
    at android.os.AsyncTask.-$$Nest$mfinish(Unknown Source:0)
    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:788)
    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:7872)
    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:936)
Caused by: java.lang.IllegalAccessException: Tried to access the API:LayoutInflater which needs to have proper configuration from a non-UI Context:net.twisterrob.inventory.android.DebugApp@f41ce72
    at android.os.StrictMode.assertConfigurationContext(StrictMode.java:2295)
    at android.view.LayoutInflater.<init>(LayoutInflater.java:260) 
    at com.android.internal.policy.PhoneLayoutInflater.<init>(PhoneLayoutInflater.java:44) 
    at android.app.SystemServiceRegistry$32.createService(SystemServiceRegistry.java:540) 
    at android.app.SystemServiceRegistry$32.createService(SystemServiceRegistry.java:537) 
    at android.app.SystemServiceRegistry$CachedServiceFetcher.getService(SystemServiceRegistry.java:1900) 
    at android.app.SystemServiceRegistry.getSystemService(SystemServiceRegistry.java:1577) 
    at android.app.ContextImpl.getSystemService(ContextImpl.java:2120) 
    at android.content.ContextWrapper.getSystemService(ContextWrapper.java:900) 
    at android.view.LayoutInflater.from(LayoutInflater.java:288) 
    at android.widget.ToastPresenter.getTextToastView(ToastPresenter.java:66) 
    at android.widget.Toast.makeText(Toast.java:503) 
    at android.widget.Toast.makeText(Toast.java:487) 
    at net.twisterrob.android.app.BaseApp.doToastUser(BaseApp.java:236) 
    at net.twisterrob.android.app.BaseApp.toastUser(BaseApp.java:230) 
    at net.twisterrob.inventory.android.view.ChangeTypeListener$ImagedVariants$1.onResult(ChangeTypeListener.java:69) 
    at net.twisterrob.android.utils.concurrent.ClosureAsyncTask.onResult(ClosureAsyncTask.java:23) 
    at net.twisterrob.android.utils.concurrent.ClosureAsyncTask.onResult(ClosureAsyncTask.java:10) 
    at net.twisterrob.android.utils.concurrent.SafeAsyncTask.onPostExecute(SafeAsyncTask.java:54) 
    at net.twisterrob.android.utils.concurrent.SafeAsyncTask.onPostExecute(SafeAsyncTask.java:12) 
    at android.os.AsyncTask.finish(AsyncTask.java:771) 
    at android.os.AsyncTask.-$$Nest$mfinish(Unknown Source:0) 
    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:788) 
    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:7872) 
    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:936)