Android的API列表&LT; cellinfo&GT; [英] Android API List<cellinfo>
问题描述
我想获得的CellInfo数据,但cellinfo.size()总是会发生 该NullPointerException异常的模拟器。
我不知道该异常的情况下,任何人都知道的原因?
无论我写了错误的code?或任何人遇到了同样的异常?
TelephonyManager TM =(TelephonyManager)本
.getSystemService(Context.TELEPHONY_SERVICE);
名单&LT; CellInfo&GT; cellinfo = TM.getAllCellInfo();
Log.d(AA,Integer.toString(cellinfo.size()));
TelephonyManager.getAllCellInfo()
在API级别17加入,这样你就可以在API级别使用17 +。
此外,您必须添加 ACCESS_COARSE_LOCATION
许可,您的清单文件:
返回 CellInfo的
列表或NULL,如果信息不可用。
要求 许可:ACCESS_COARSE_LOCATION
<一个href="http://developer.android.com/reference/android/telephony/TelephonyManager.html#getAllCellInfo%28%29"相对=nofollow>请参见文档
I would like to get the CellInfo data, but the cellinfo.size() always occur the NullPointerException in Emulator.
I am not sure the exception situation, anyone know the reason?
Whether I wrote the wrong code? or anyone met the same exception?
TelephonyManager TM = (TelephonyManager) this
.getSystemService(Context.TELEPHONY_SERVICE);
List<CellInfo> cellinfo = TM.getAllCellInfo();
Log.d("AA",Integer.toString(cellinfo.size()));
TelephonyManager.getAllCellInfo()
is added in API level 17, so you can use it on Api Level 17 and +.
Also you must add ACCESS_COARSE_LOCATION
permission to your manifest file:
Returns
List of CellInfo or null if info unavailable.
Requires Permission: ACCESS_COARSE_LOCATION
这篇关于Android的API列表&LT; cellinfo&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!