7

I want to be able to post notifications, show toasts, and start/stop services from my Xposed module, to do that I need a Context. Does my Xposed module have it's own Context? If not, can I get one by hooking into another process? Which process would I want to hook into?

Daniel
  • 2,728
  • 3
  • 21
  • 33

1 Answers1

7

The Xposed Module in itself is installed as an application, so you can add activities and retrieve the context like in any normal application.

It depends on where you want to launch the Toast messages. As you seem to know, every application runs on its own process (and VM) and each process/app has its own copy of your Xposed module classes.

If you built your Xposed module with activities, then you can retrieve the context (e.g. retrieving context) normally within your xposed app.

BUT, since these activities are running within their own process (installed xposed module), this context will not be accessible in other apps running a copy of your Xposed module code.

So, in applications you are actually hooking (the ones you handle in "handleLoadPackage"), you can always hook Activity or broadcast receivers methods to retrieve their context (check this).

4knahs
  • 629
  • 4
  • 14
  • 3
    I ended up doing something similar (my Xposed module hooked into the onStart method of class Activity, so I "stole" the context from them to send a broadcast to my Xposed module's receiver so it can do the advanced stuff that I wanted it to do) - I forgot to get back to this question and post my findings. Thanks for the detailed answer :) – Daniel Nov 14 '14 at 07:17