In my Android app I'm trying to get the user's phone number. I tried the TelephonyManager solution but here in Europe 90% of the SIM cards have that field blank, so the function returns NULL.
I think I could get the user's phone number searching for sent SMS or by querying the Google account. For the SMS method, I tried to load the content provider sms/sent, but the only address field I can extract is the phone number of the person the user sent the SMS to.
For the Google account I have no idea on what to do.
private String getMyPhoneNumber() {
TelephonyManager mTelephonyMgr;
mTelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
return mTelephonyMgr.getLine1Number();
}
Try this, I'm from Poland, and it works well.
解决方案:清单的包名是de.org.limindo.limindo2,但apk的包是de.org.limindo2 .....
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.