rovo89 / XposedBridge

The Java part of the Xposed framework.
3.86k stars 1.1k forks source link

Share data between module and my application. #252

Open DoodleWing opened 6 years ago

DoodleWing commented 6 years ago

When I' ve hooked a calling of a method, I want to send a message to my main application to show a notification or a toast to make users notified. How could I do it? I don't know how to share data between my hook module and my main application because the module runs in processes where hooked method runs. Sorry for my poor English XD

C3C0 commented 6 years ago

One of the alternatives is to create a service within your main app. You can then bind to such service from a foreign app and tell it what to do. https://developer.android.com/guide/components/bound-services Using Messenger approach would be enough in this case.

voider1 commented 6 years ago

The way I solved it is using Intents. Create a BroadcastReceiver in your main application and make your module send an Intent to it with the data you want to show.

DoodleWing commented 6 years ago

I' ve worked it out, thanks a lot! Here comes another problem. Is sharedPreference being set as MODE_WORLD_READABLE absolutely needed? I couldn' t perform it on Android N.

Android1500 commented 3 years ago

I' ve worked it out, thanks a lot! Here comes another problem. Is sharedPreference being set as MODE_WORLD_READABLE absolutely needed? I couldn' t perform it on Android N.

you got solution??