aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/pixart/messenger/services/XmppConnectionService.java')
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index 153c1c269..16ebd8c11 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -896,6 +896,46 @@ public class XmppConnectionService extends Service {
return activeNetwork != null && activeNetwork.isConnected();
}
+ public boolean isWIFI() {
+ ConnectivityManager cm = (ConnectivityManager) getApplicationContext()
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
+ if (activeNetwork != null) { // connected to the internet
+ if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean isMobile() {
+ ConnectivityManager cm = (ConnectivityManager) getApplicationContext()
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
+ if (activeNetwork != null) { // connected to the internet
+ if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) {
+ if (!activeNetwork.isRoaming()) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public boolean isMobileRoaming() {
+ ConnectivityManager cm = (ConnectivityManager) getApplicationContext()
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
+ if (activeNetwork != null) { // connected to the internet
+ if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) {
+ if (activeNetwork.isRoaming()) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
@SuppressLint("TrulyRandom")
@Override
public void onCreate() {