Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve the number and IMEI of the mobile phone

Tags:

android

I want to retrieve the own mobile number and the IMEI.

How do I get this information from the Android phone?

like image 886
Maidul Avatar asked Jun 18 '11 06:06

Maidul


Video Answer


1 Answers

use

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

but its not always reliable on for example non phone device.

and you should also add this following permission to your AndroidManifest.xml file

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
like image 131
mkso Avatar answered Nov 02 '22 19:11

mkso