public boolean checkInternetConnection() {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (cm.getActiveNetworkInfo() != null && cm.getActiveNetworkInfo().isAvailable() && cm.getActiveNetworkInfo().isConnected()) {
return true;
} else {
return false;
}
}
Sebelum menggunakan function atau method ini, jangan lupa untuk men setting permission di AndroidManifest nya. Semoga bermanfaat
Oleh: Wahyu Kurniawan

0 comments:
Post a Comment