use
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
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"/>
source
share