2011-02-11 134 views
5

我看到有很多关于如何拨打号码的例子,而且我也看到我只能让拨号程序弹出一个紧急号码。但在所有这些例子中,他们都将硬编码为“911”作为使用的数字。这在美国运作良好,但由于Android手机在其他国家销售,因此有可能我的应用程序将由不在美国的人购买,或者居住在美国的人可能会将手机带到海外;有没有办法,那么我的应用程序可以意识到它不在我们的身上,因此必须使用不同的号码来呼叫紧急服务以及该号码是什么?android如何获得拨打紧急号码

所以总结一下,我想知道是否有办法让我可以拥有它,所以当应用程序将拨号程序与紧急号码一起提供给所在国家时,无需知道该号码在complie时间?

+0

请看下面的答案使用SystemProperties: [使用SystemProperties] [1] [1]:http://stackoverflow.com/questions/2641111/where-is-android-os -systemproperties – 2012-06-24 11:07:24

回答

4

据该人士为PhoneNumberUtils.isEmergencyNumber()

String numbers = SystemProperties.get("ril.ecclist"); 
if (TextUtils.isEmpty(numbers)) { 
    // then read-only ecclist property since old RIL only uses this 
    numbers = SystemProperties.get("ro.ril.ecclist"); 
} 

数字将是一个逗号分隔的列表。

+0

它不起作用,当我尝试时,它给了我一个错误,说SystemProperties不存在。 我也尝试过以另一种方式做它太极其无效 `String numbers = System.getProperty(“ril.ecclist”); Log.d(“数字”,“!”+数字); if(TextUtils.isEmpty(numbers)) { \t numbers = System.getProperty(“ro.ril.ecclist”); } Log.d(“数字”,“!”+数字);` 让我编译但数字可变是空的时间。 – 2011-02-12 19:46:29