/**
* Retrieves network operator names from subscription manager.
* NOTE: Requires SDK level 22 or above
*
* @param context
* @return
*/
private static String getNetworkOperators(Context context) {
String operator = "";
if (!PermissionsUtils.checkPermission(context, Manifest.permission.READ_PHONE_STATE)) {
return operator;
}
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) {
SubscriptionManager subscriptionManager = SubscriptionManager.from(context);
if (subscriptionManager != null) {
List<SubscriptionInfo> subscriptions = subscriptionManager.getActiveSubscriptionInfoList();
if (subscriptions != null) {
for (SubscriptionInfo info : subscriptions) {
CharSequence carrierName = info.getCarrierName();
if (carrierName != null && carrierName.length() > 0) {
operator += carrierName + ";";
}
}
// Remove last delimiter
if (operator.length() >= 1) {
operator = operator.substring(0, operator.length() - 1);
}
}
}
}
return operator;
}
Phone.java 文件源码
java
阅读 31
收藏 0
点赞 0
评论 0
项目:batteryhub
作者:
评论列表
文章目录