How to get my phonenumber
I am looking for a way to get my phone number... the .getLine1Number() retur开发者_运维百科ns null, is there any alternative?
There could be several reasons...
Are you using an emulator? If so then it won't have an phone number
Are you using a tablet? Same as above
Have you added this permission in the manifest?
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
Are you using the correct code?
TelephonyManager mTelephonyMgr;
mTelephonyMgr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
mTelephonyMgr.getLine1Number();
精彩评论