androidandroid-contextandroid-inflatexposed-framework

Get xml View or Context from Xposed Module


I'm developing a Xposed module, I've searched and I haven't found the answer.

But I've found this and I don't know how/what getObjectField() work/need, and also I've found this but it need my app context. I can get a context from the system but I need to get a view from my exposed module and inflate/add it in some part of the system UI and I don't know how I can do this.

To be clear:

Does Xposed provide a easy way to get views from my module?


Solution

  • My xposed module "SnapColors" does all this and is open source you can take a look at the source.

    Github SnapColors: https://github.com/Programming4life/SnapColors

    Module context: You shouldn't do this some devices have security restrictions which prevent you from doing this, instead take a look at "Layout Inflating:" section but never the less here's how to do it.

    Context moduleContext = AndroidAppHelper.currentApplication().createPackageContext("yourModulePackageName", Context.CONTEXT_IGNORE_SECURITY);
    

    Source: createPackageContext (String packageName, int flags)

    Layout Inflating: https://github.com/Programming4life/SnapColors/blob/master/app/src/main/java/com/manvir/SnapColors/TextureLayout.java#L34

    hookLayout Example: https://github.com/Programming4life/SnapColors/blob/master/app/src/main/java/com/manvir/SnapColors/App.java#L73