blob: 62a8f0adfbe76996715e889501398150169c183f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
package se.leap.bitmaskclient.test;
import android.content.Context;
import android.net.ConnectivityManager;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import android.util.Log;
public class ConnectionManager {
static void setMobileDataEnabled(boolean enabled, Context context) {
final ConnectivityManager conman = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
Method[] methods = conman.getClass().getMethods();
for (Method method : methods) {
if (method.getName().equals("setMobileDataEnabled")) {
method.setAccessible(true);
try {
method.invoke(conman, enabled);
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
}
}
|