- 论坛徽章:
- 0
|
What you learn: You will learn how to read out the phonenumber of the device
your application is running on.
Difficulty: 1 of 5 Smile
Idea Questions/Problems: Simply post below...
Description:
Nothing is easier to be done, if you know where to search for
it Smile
The SystemProperties provide a bunch of data of the current
Phone-'Properties', like:
* the operator-Name (i.e.: "T-Mobile" or "AT&T"
* the
ISO-Country-Name (i.e.: "us" or "de")
* and of course your Phone-Number
Exclamation
This is how to get these Strings into your Java-Code:
Java:
String
phoneNumber = android.os.SystemProperties.get(
android.telephony.TelephonyProperties.PROPERTY_LINE1_NUMBER);
String
operatorISOCountry = android.os.SystemProperties.get(
android.telephony.TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY);
String
operatorName =android.os.SystemProperties.get(
android.telephony.TelephonyProperties.PROPERTY_OPERATOR_ALPHA);;
On the emulator this will return: "15555218135", "us" and "Android".
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/85805/showart_1772395.html |
|