List of usage examples for android.content Context TELEPHONY_SERVICE
String TELEPHONY_SERVICE
To view the source code for android.content Context TELEPHONY_SERVICE.
Click Source Link
From source file:com.gmobi.poponews.util.HttpHelper.java
public JSONObject getDeviceInfo() { ;//from ww w .j a v a 2 s . c o m TelephonyManager mTelephonyMgr = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); String imsi = mTelephonyMgr.getSubscriberId(); String imei = mTelephonyMgr.getDeviceId(); JSONObject json = new JSONObject(); try { json.put("app", mContext.getPackageName()); json.put("ch", PreferenceHelper.getCurChannel(mContext)); json.put("group", BuildConfig.GROUP); json.put("app_v", SystemHelper.getAppVersion(mContext)); json.put("imsi", imsi); json.put("imei", imei); json.put("sd", SystemHelper.hasSdcard(mContext)); json.put("ua", SystemHelper.getUA(false)); json.put("os", "android"); json.put("os_v", SystemHelper.getOsVersion()); json.put("lang", Locale.getDefault().getLanguage()); json.put("country", SystemHelper.getCountry(mContext)); json.put("wmac", SystemHelper.getWifiMac(mContext)); json.put("bmac", ""); json.put("sn", SystemHelper.getAndroidId(mContext)); json.put("sa", SystemHelper.isSystemApp(mContext)); json.put("sw", SystemHelper.getScreenWidth(mContext)); json.put("sh", SystemHelper.getScreenHeight(mContext)); json.put("dch", BuildConfig.DISTRIBUTION_CHANNEL); json.put("gref", new JSONObject("{}")); Logger.debug("Send Device Info: " + json.toString(4)); } catch (JSONException e) { Logger.error(e); } return json; }
From source file:com.yamin.kk.vlc.Util.java
public static boolean isPhone() { TelephonyManager manager = (TelephonyManager) VLCApplication.getAppContext() .getSystemService(Context.TELEPHONY_SERVICE); if (manager.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE) { return false; } else {/*from w ww .j a v a 2 s . c o m*/ return true; } }
From source file:com.otaupdater.utils.Utils.java
public static String getDeviceID(Context ctx) { if (deviceID != null) return deviceID; deviceID = ((TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId(); if (deviceID == null) { WifiManager wm = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE); if (wm.isWifiEnabled()) { deviceID = wm.getConnectionInfo().getMacAddress(); } else {//from ww w. j a va 2 s . co m //fallback to ANDROID_ID - gets reset on data wipe, but it's better than nothing deviceID = Settings.Secure.getString(ctx.getContentResolver(), Settings.Secure.ANDROID_ID); } } deviceID = md5(deviceID); return deviceID; }
From source file:riddimon.android.asianetautologin.HttpUtils.java
/** * Uses TelephonyManager and WifiManager to check for network connectivity. * Also incorporates CONNECTING state for retry scenarios. * @param context/* w ww .ja v a2 s. co m*/ * @return ConnectionStatus */ public ConnectionStatus isConnectedOLD(Context context) { boolean data = false, wifi = false; boolean data_connecting = false, wifi_connecting = false; TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); int ds = tm.getDataState(); int ws = wm.getWifiState(); switch (ds) { case TelephonyManager.DATA_CONNECTED: data = true; break; case TelephonyManager.DATA_CONNECTING: data_connecting = true; default: data = false; data_connecting = false; } switch (ws) { case WifiManager.WIFI_STATE_ENABLING: wifi_connecting = true; case WifiManager.WIFI_STATE_DISABLING: case WifiManager.WIFI_STATE_DISABLED: case WifiManager.WIFI_STATE_UNKNOWN: wifi = false; break; case WifiManager.WIFI_STATE_ENABLED: WifiInfo wi = wm.getConnectionInfo(); if (wi != null) wifi = true; break; } if (wifi && data) return ConnectionStatus.BOTH_CONNECTED; else if (wifi && data_connecting) return ConnectionStatus.WIFI_CONNECTED; else if (data && wifi_connecting) return ConnectionStatus.DATA_CONNECTED; else if (wifi_connecting || data_connecting) return ConnectionStatus.CONNECTING; return ConnectionStatus.NO_CONNECTION; }
From source file:com.lewen.listener.vlc.Util.java
public static boolean isPhone() { TelephonyManager manager = (TelephonyManager) TBApplication.App.getApplicationContext() .getSystemService(Context.TELEPHONY_SERVICE); if (manager.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE) { return false; } else {//from w w w .j a va 2 s. c o m return true; } }
From source file:com.otaupdater.utils.Utils.java
public static String getDeviceName(Context ctx) { if (deviceName != null) return deviceName; deviceName = ((TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE)).getNetworkOperatorName(); if (deviceName == null || deviceName.isEmpty()) deviceName = "Wi-Fi"; deviceName += " " + Build.MODEL; return deviceName.trim(); }
From source file:com.polyvi.xface.extension.telephony.XTelephonyExt.java
/** * sim???/*from w w w . j ava 2 s . c om*/ * * @param context * @return */ public boolean isSimCardAvailable(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return (info != null && info.isConnected() && checkSimCardState(tm)); }