Read phone number from Tablet : Android
In my application I read device phone number as
TelephonyManager telephonyManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
// Read phone number of device owner.
String phoneNumber = telephonyManager.getLine1Number();
where, this will work till device having phone application.
But whe开发者_如何学Cn using device is a tablet(some tablet doesn't have phone application), then what will be the value of phoneNumber? Is it will null or blank String? Or it will be an error?
I couldn't check it on emulator because SDK having Samsung Galaxy tab and that having Phone app.
this will work till device having phone application.
No, it will not. It is dependent upon what phone number was programmed into the SIM card. On some phones, this returns null
. On my personal phone, it returns the wrong phone number. Do not rely upon getLine1Number()
for much of anything.
Is it will null or blank String?
I am reasonably certain that it will return null
. It should not raise an Exception
.
精彩评论