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

StrictMode error Tried to access visual service WindowManager from a non-visual Context #476

Open
LluisFelip opened this issue Mar 7, 2024 · 0 comments

Comments

@LluisFelip
Copy link

Hello!

On our app we are using mParticle and we've recently found out, when enabling StrictMode we are seeing these errors every time we are logging an event:

Tried to access visual service WindowManager from a non-visual Context:glovoapp.App@9be9157 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.
java.lang.IllegalAccessException: Tried to access visual service WindowManager from a non-visual Context:glovoapp.App@9be9157
      at android.app.ContextImpl.getSystemService(ContextImpl.java:2208)
      at android.content.ContextWrapper.getSystemService(ContextWrapper.java:935)
      at com.mparticle.internal.MPUtility.getOrientation(SourceFile:1)
      at com.mparticle.internal.j.n(SourceFile:21)
      at com.mparticle.internal.i.a(SourceFile:364)
      at com.mparticle.b.handleMessage(SourceFile:17)
      at android.os.Handler.dispatchMessage(Handler.java:107)
      at android.os.Looper.loopOnce(Looper.java:232)
      at android.os.Looper.loop(Looper.java:317)
      at android.os.HandlerThread.run(HandlerThread.java:68)

After exploring a little bit what could this be, found out this MPUtility.getOrientation(context: Context) (link) is using an ApplicationContext coming from MessageManager (link), which is initialized above using the options.getContext().getApplicationContext() (link).

Not sure if this will help, just thought of sharing and seeing if it could be avoided. Not sure what the orientation is used for, but maybe could be an optional check, as it would be great to not have these IllegalAccessException every time something is tracked 😄 .

Thanks a lot in advance!

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

No branches or pull requests

1 participant