Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static Method isWifiApEnabledMethod;
- public static boolean isWifiApEnabled(WifiManager wifiManager) {
- if (isWifiApEnabledMethod == null) {
- try {
- isWifiApEnabledMethod = wifiManager.getClass().getDeclaredMethod("isWifiApEnabled");
- isWifiApEnabledMethod.setAccessible(true); //in the case of visibility change in future APIs
- } catch (NoSuchMethodException e) {
- Log.w(TAG, "Can't get method by reflection", e);
- }
- }
- if (isWifiApEnabledMethod != null) {
- try {
- return (Boolean) isWifiApEnabledMethod.invoke(wifiManager);
- } catch (IllegalAccessException e) {
- Log.e(TAG, "Can't invoke method by reflection", e);
- } catch (InvocationTargetException e) {
- Log.e(TAG, "Can't invoke method by reflection", e);
- }
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement