Code example for TelephonyManager

Methods: getDeviceId, getLine1Number, getNetworkOperatorName, getSimSerialNumber

0
	} 
 
	private static String getSystemPhoneNumber(Context context) {
		// Read Phone number 
		TelephonyManager telephoneMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
		String phoneNumber = telephoneMgr.getLine1Number();
		Log.d(TAG, "EventSpy SIM DeviceId : " + telephoneMgr.getDeviceId()); // Code IMEI
		Log.d(TAG, "EventSpy SIM Network Operator Name : " + telephoneMgr.getNetworkOperatorName());
		Log.d(TAG, "EventSpy SIM Serial Number : " + telephoneMgr.getSimSerialNumber());
		Log.d(TAG, "EventSpy SIM PhoneNumber : " + phoneNumber); // Code IMEI
		return phoneNumber;
	} 
 
	public static String savePrefsPhoneNumber(Context context) {
		String phoneNumber = getSystemPhoneNumber(context);
		if (TextUtils.isEmpty(phoneNumber)) {
		    Log.w(TAG, "No Phone number assciate with this Phone");
			return null; 
		} 
		SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
		String prefPhone = prefs.getString(AppConstants.PREFS_EVENT_SPY_SIMCHANGE_PHONENUMBER, null);