Get Mobile Phone Number and IMEI

I want to get my own mobile number and IMEI.

How to get this information from an Android phone?

+5
source share
2 answers

use

TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
// get IMEI
String imei = tm.getDeviceId();
String phone = tm.getLine1Number();

but it is not always reliable, for example, for a non-telephone device.

and you should also add this next permission to your AndroidManifest.xmlfile

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
+17
source

getLine1Number();

this method returns the line of the phone number for line 1,
that is, the MSISDN for the GSM phone . Returns null if it is unavailable.

but what about a cdma phone ?

:

.

+2

All Articles