For Checking the Internet connection either WIFI or DataConnection---------->
public static boolean checkConnection(Context c)
{
ConnectivityManager mConnectivityManager = (ConnectivityManager) c
.getSystemService(Context.CONNECTIVITY_SERVICE);
TelephonyManager telephonyManager = (TelephonyManager) c
.getSystemService(Context.TELEPHONY_SERVICE);
if (mConnectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
.isConnected() || telephonyManager.getDataState() == TelephonyManager.DATA_CONNECTED)
return true;
else
return false;
// return true;
}
For retrieving IMEI or MACAddress----------->
public String getDevice_ID() {
IMEI_NO = ((TelephonyManager) getSystemService(TELEPHONY_SERVICE))
.getDeviceId();
if (IMEI_NO == null || IMEI_NO == "358673013795895") {
Log.d(TAG, "IMEI is null");
IMEI_NO = ((WifiManager) (getSystemService(WIFI_SERVICE)))
.getConnectionInfo().getMacAddress();
Log.d(TAG, "Mac address is:" + IMEI_NO);
}
No comments:
Post a Comment