Java tutorial
//package com.java2s; /* * Copyright (C) 2011 The LiteListen Project * * Licensed under the Mozilla Public Licence, version 1.1 (the "License"); * You may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.mozilla.org/MPL/MPL-1.1.html * * 2011 * Mozilla Public Licence 1.1 * * * * http://www.mozilla.org/MPL/MPL-1.1.html */ import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class Main { public static boolean IsWiFiConnected(Context context) { ConnectivityManager connectivity = (ConnectivityManager) context.getApplicationContext() .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivity != null) { NetworkInfo[] info = connectivity.getAllNetworkInfo(); if (info != null) { for (int i = 0; i < info.length; i++) { if (info[i].getTypeName().equals("WIFI") && info[i].isConnected()) return true; } } } return false; } }