Hook to BroadcastReceiver using Xposed Framework

1.1k views Asked by At

How to hook a onReceive method inside BroadcastReceiver?

public class RecentsActivity extends Activity
{
  mIntentReceiver = new BroadcastReceiver()
  {
    public void onReceive(Context context, Intent intent)
    {
      ...
    }
  };
}
1

There are 1 answers

1
4knahs On BEST ANSWER

Since the BroadcastReceiver is an abstract class and this is an inline class definition, perhaps you can retrieve this BroadcastReceiver this way:

for(Class<?> cls : <package_name>.RecentsActivity.class.getDeclaredClasses()){
    if(BroadcastReceiver.isAssignableFrom(cls)){
        //hook onReceive
    }
}

Otherwise try to check the application smali code using the apktool.

There probably is a file named RecentsActivity$N (where N is a number). Just do Class.forName("<packagename>.RecentsActivity$N") and hook this class onReceive method.

Good luck!