2008/3/23

如何找出EMULATOR的電話號碼

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".

reference: [origin]

沒有留言: