mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-22 03:54:18 -04:00
Refactor isMobileDataEnabled
This commit is contained in:
parent
887edc7ad8
commit
815ad025d7
@ -186,18 +186,17 @@ public class ZimHostActivity extends AppCompatActivity implements
|
||||
|
||||
// This method checks if mobile data is enabled in user's device.
|
||||
static boolean isMobileDataEnabled(Context context) {
|
||||
boolean enabled = false;
|
||||
ConnectivityManager cm =
|
||||
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
try {
|
||||
Class cmClass = Class.forName(cm.getClass().getName());
|
||||
Method method = cmClass.getDeclaredMethod("getMobileDataEnabled");
|
||||
method.setAccessible(true);
|
||||
enabled = (Boolean) method.invoke(cm);
|
||||
return (Boolean) method.invoke(cm);
|
||||
} catch (Exception e) {
|
||||
Log.e("ZimHostActivity", e.toString());
|
||||
}
|
||||
return enabled;
|
||||
return false;
|
||||
}
|
||||
|
||||
//This method sends the user to data usage summary settings activity
|
||||
|
Loading…
x
Reference in New Issue
Block a user