- if (receiverClass.getName().contains("ProxyChangeListener")) {
- Method onReceiveMethod = receiverClass.getDeclaredMethod("onReceive", Context.class, Intent.class);
- Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION);
- onReceiveMethod.invoke(receiver, privacyBrowserContext, intent);
+
+ // Get the declared fields.
+ final Field[] declaredFieldArray = receiverClass.getDeclaredFields();
+
+ // Set the proxy for each field that is a `ProxyChangeListener`.
+ for (Field field : declaredFieldArray) {
+ if (field.getType().getName().contains("ProxyChangeListener")) {
+ Method onReceiveMethod = receiverClass.getDeclaredMethod("onReceive", Context.class, Intent.class);
+ Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION);
+ onReceiveMethod.invoke(receiver, privacyBrowserContext, intent);
+ }