From a4e3ab13a1ff628715325d15f56ed5043ccf482d Mon Sep 17 00:00:00 2001 From: lado Date: Sun, 6 Nov 2011 23:43:59 +0100 Subject: connection check --- vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java index b2bb144..9e6ed41 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java @@ -12,6 +12,7 @@ import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.graphics.Color; +import android.net.ConnectivityManager; import android.net.Uri; import android.text.Spannable; import android.text.SpannableString; @@ -238,5 +239,16 @@ public class Utils { } return pi; } + + public static boolean checkInternetConnection(Context ctx) { + ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE); + // test for connection + if (cm.getActiveNetworkInfo() != null + && cm.getActiveNetworkInfo().isAvailable() + && cm.getActiveNetworkInfo().isConnected()) { + return true; + } + return false; + } } -- cgit v1.2.3