0

I have three classes:

MyPlugin extends OtherPluginClass extends Service
MyService extends AccesibilityService
LoggerClass implements BaseLoggerClass

MyService starts when the user authorizes it in Accessibility settings. MyPlugin is started and controlled by a different application (tho' I have access to its source code).

The problem is the LoggerClass is coordinated by MyService, however LoggerClass needs the context of MyPlugin to perform some operations.

I've tried to create a static sharedContext variable in MyPlugin and populate it in the onCreate method, but LoggerClass always sees sharedContext as null.

What would be the best way for LoggerClass to access MyPlugin's context?

Julio Vga
  • 143
  • 1
  • 7
  • Simply put: it can't. They're completely separate processes. If you phrase it like: "I need to accomplish this..." we might be able to help. – MobA11y Mar 09 '16 at 14:35
  • At the end I solved it by creating a method public static MyPlugin get(){ return plugin; } And then in the MyPlugin's constructor plugin = this; Is this a safe solution? – Julio Vga Mar 10 '16 at 11:44
  • No. If it's started by a different application, you may no longer be seeing null, but they're going to be separate objects. A working solution is going to involve some form of cross process communication. Intents, broadcast receivers, etc. It may be "safe" as in your not getting null returned from your "sharedContext" but you're not sharing the same object. – MobA11y Mar 10 '16 at 14:40

0 Answers0