Skip to content
Snippets Groups Projects
Commit 8c631ac3 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Utility methods for checking deivce connextion type

parent f7e0a4bd
No related branches found
Tags 3.0.0-rc4
No related merge requests found
......@@ -218,6 +218,31 @@ public class AndroidDevices {
return networkEnabled;
}
public static boolean hasConnection() {
boolean networkEnabled = false;
ConnectivityManager connectivity = (ConnectivityManager) (VLCApplication.getAppContext().getSystemService(Context.CONNECTIVITY_SERVICE));
if (connectivity != null) {
NetworkInfo networkInfo = connectivity.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.isConnected()) {
networkEnabled = true;
}
}
return networkEnabled;
}
public static boolean hasMobileConnection() {
boolean networkEnabled = false;
ConnectivityManager connectivity = (ConnectivityManager) (VLCApplication.getAppContext().getSystemService(Context.CONNECTIVITY_SERVICE));
if (connectivity != null) {
NetworkInfo networkInfo = connectivity.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.isConnected() &&
(networkInfo.getType() == ConnectivityManager.TYPE_MOBILE)) {
networkEnabled = true;
}
}
return networkEnabled;
}
public static void setRemoteControlReceiverEnabled(boolean enabled) {
VLCApplication.getAppContext().getPackageManager().setComponentEnabledSetting(
new ComponentName(VLCApplication.getAppContext(), RemoteControlClientReceiver.class),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment