• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SubscriptionInfo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中android.telephony.SubscriptionInfo的典型用法代码示例。如果您正苦于以下问题:Java SubscriptionInfo类的具体用法?Java SubscriptionInfo怎么用?Java SubscriptionInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SubscriptionInfo类属于android.telephony包,在下文中一共展示了SubscriptionInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getActiveSubscriptionInfoList

import android.telephony.SubscriptionInfo; //导入依赖的package包/类
public @NonNull List<SubscriptionInfoCompat> getActiveSubscriptionInfoList() {
  if (Build.VERSION.SDK_INT < 22) {
    return new LinkedList<>();
  }

  List<SubscriptionInfo> subscriptionInfos = SubscriptionManager.from(context).getActiveSubscriptionInfoList();

  if (subscriptionInfos == null || subscriptionInfos.isEmpty()) {
    return new LinkedList<>();
  }

  List<SubscriptionInfoCompat> compatList = new LinkedList<>();

  for (SubscriptionInfo subscriptionInfo : subscriptionInfos) {
    compatList.add(new SubscriptionInfoCompat(subscriptionInfo.getSubscriptionId(),
                                              subscriptionInfo.getDisplayName()));
  }

  return compatList;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:21,代码来源:SubscriptionManagerCompat.java


示例2: setDefaultSubscription

import android.telephony.SubscriptionInfo; //导入依赖的package包/类
private boolean setDefaultSubscription(final SubType subType, final SubscriptionInfo subInfo) {
    if (subInfo == null)
        return false;

    try {
        if (subType == SubType.SMS) {
            XposedHelpers.callMethod(mSubMgr, "setDefaultSmsSubId",
                    subInfo.getSubscriptionId());
        } else if (subType == SubType.DATA) {
            XposedHelpers.callMethod(mSubMgr, "setDefaultDataSubId",
                    subInfo.getSubscriptionId());
        }
        return true;
    } catch (Throwable t) {
        XposedBridge.log(t);
        return false;
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:19,代码来源:SubscriptionManager.java


示例3: getDefaultVoiceSubscriptionSimSlot

import android.telephony.SubscriptionInfo; //导入依赖的package包/类
private int getDefaultVoiceSubscriptionSimSlot() {
    try {
        final TelecomManager telecomManager =
                (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
        final TelephonyManager telephonyManager =
                (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
        PhoneAccountHandle pah = (PhoneAccountHandle) XposedHelpers.callMethod(telecomManager,
                "getUserSelectedOutgoingPhoneAccount");
        if (pah != null) {
            PhoneAccount pa = telecomManager.getPhoneAccount(pah);
            int subId = getSubIdForPhoneAccount(telephonyManager, pa);
            SubscriptionInfo si = mSubMgr.getActiveSubscriptionInfo(subId);
            if (si != null) {
                return si.getSimSlotIndex();
            }
        }
        return -1;
    } catch (Throwable t) {
        XposedBridge.log(t);
        return -1;
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:23,代码来源:SubscriptionManager.java


示例4: onHandleIntent

import android.telephony.SubscriptionInfo; //导入依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
    log.d("onHandleIntent");
    //SubscriptionManager  该类主要包含了所有sim卡的信息
    SubscriptionManager mSubscriptionManager = SubscriptionManager.from(this);
    int simcnt = mSubscriptionManager.getActiveSubscriptionInfoCount();
    List<SubscriptionInfo> lstSim = mSubscriptionManager.getActiveSubscriptionInfoList();
    for (int i = 0; i < lstSim.size(); i++) {
        SubscriptionInfo si = lstSim.get(i);
        if (si != null)
            log.d(si.toString());
    }
    TelecomManager telecomManager = (TelecomManager) getSystemService(Context.TELECOM_SERVICE);
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) {
        List<PhoneAccountHandle> lstPA=telecomManager.getCallCapablePhoneAccounts();
        int accoutSum =lstPA.size();
        for(int i=0;i<accoutSum;i++)
            log.d("accountSum: " + accoutSum +lstPA.get(i) );
    }

}
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:22,代码来源:SimService.java


示例5: changeDefaultSub

import android.telephony.SubscriptionInfo; //导入依赖的package包/类
public void changeDefaultSub(final SubType subType, final int simSlot, final boolean showToast) {
    boolean result;
    SubscriptionInfo si = mSubMgr.getActiveSubscriptionInfoForSimSlotIndex(simSlot);
    if (subType == SubType.VOICE) {
        if (si == null && (simSlot == 0 || simSlot == 1)) {
            result = false;
        } else {
            result = setDefaultVoiceSubscription(si);
        }
    } else {
        result = setDefaultSubscription(subType, si);
    }
    if (showToast || !result) {
        final String msg = result ? getChangeOkMsg(subType, getSubDisplayName(si)) :
            getChangeFailedMsg(subType);
        Toast.makeText(mContext, msg, Toast.LENGTH_LONG).show();
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:19,代码来源:SubscriptionManager.java


示例6: getSubItemList

import android.telephony.SubscriptionInfo; //导入依赖的package包/类
private List<IIconListAdapterItem> getSubItemList(final SubType subType) {
    List<IIconListAdapterItem> list = new ArrayList<>();
    if (subType == SubType.VOICE) {
        list.add(new SubListItem(null));
        final TelecomManager telecomManager = 
                (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
        final TelephonyManager telephonyManager =
                (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
        final Iterator<PhoneAccountHandle> phoneAccounts =
                telecomManager.getCallCapablePhoneAccounts().listIterator();
        while (phoneAccounts.hasNext()) {
            final PhoneAccount phoneAccount =
                    telecomManager.getPhoneAccount(phoneAccounts.next());
            int subId = getSubIdForPhoneAccount(telephonyManager, phoneAccount);
            if (subId != -1) {
                list.add(new SubListItem(mSubMgr.getActiveSubscriptionInfo(subId)));
            }
        }
    } else {
        for (SubscriptionInfo si : mSubMgr.getActiveSubscriptionInfoList())
            if (si != null)
                list.add(new SubListItem(si));
    }
    return list;
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:26,代码来源:SubscriptionManager.java


示例7: subscriptionToPhoneAccountHandle

import android.telephony.SubscriptionInfo; //导入依赖的package包/类
private PhoneAccountHandle subscriptionToPhoneAccountHandle(final SubscriptionInfo subInfo) {
    if (subInfo == null)
        return null;

    final TelecomManager telecomManager =
            (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
    final TelephonyManager telephonyManager =
            (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
    final Iterator<PhoneAccountHandle> phoneAccounts =
            telecomManager.getCallCapablePhoneAccounts().listIterator();
    while (phoneAccounts.hasNext()) {
        final PhoneAccountHandle phoneAccountHandle = phoneAccounts.next();
        final PhoneAccount phoneAccount = telecomManager.getPhoneAccount(phoneAccountHandle);
        if (subInfo.getSubscriptionId() == getSubIdForPhoneAccount(telephonyManager, phoneAccount)) {
            return phoneAccountHandle;
        }
    }

    return null;
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:21,代码来源:SubscriptionManager.java


示例8: getActiveSubscriptionInfoList

import android.telephony.SubscriptionInfo; //导入依赖的package包/类
public @NonNull List<SubscriptionInfoCompat> getActiveSubscriptionInfoList() {
  if (Build.VERSION.SDK_INT < 22) {
    return new LinkedList<>();
  }

  List<SubscriptionInfo> subscriptionInfos = SubscriptionManager.from(context).getActiveSubscriptionInfoList();

  if (subscriptionInfos == null || subscriptionInfos.isEmpty()) {
    return new LinkedList<>();
  }

  List<SubscriptionInfoCompat> compatList = new LinkedList<>();

  for (SubscriptionInfo subscriptionInfo : subscriptionInfos) {
    compatList.add(new SubscriptionInfoCompat(subscriptionInfo.getSubscriptionId(),
                                              subscriptionInfo.getDisplayName(),
                                              subscriptionInfo.getMcc(),
                                              subscriptionInfo.getMnc()));
  }

  return compatList;
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:23,代码来源:SubscriptionManagerCompat.java


示例9: fillDualSimList

import android.telephony.SubscriptionInfo; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP_MR1)
private void fillDualSimList(PreferenceScreen preferenceScreen) {
    PreferenceCategory category = (PreferenceCategory) preferenceScreen.findPreference("sms_category");
    ListPreference preference = (ListPreference) category.findPreference(Preferences.DUALSIM_SIM);
    List<String> simIds = new ArrayList<>();
    List<String> simNames = new ArrayList<>();
    simIds.add(String.valueOf(Preferences.VALUE_DEFAULT_SIM));
    simNames.add(getString(R.string.sim_default));
    SubscriptionManager subscriptionManager = SubscriptionManager.from(getActivity());
    for (SubscriptionInfo subscriptionInfo : subscriptionManager.getActiveSubscriptionInfoList()) {
        simIds.add(String.valueOf(subscriptionInfo.getSubscriptionId()));
        simNames.add(getString(R.string.sim_name, subscriptionInfo.getSimSlotIndex() + 1, subscriptionInfo
            .getDisplayName()));
    }
    preference.setEntries(simNames.toArray(new String[simNames.size()]));
    preference.setEntryValues(simIds.toArray(new String[simIds.size()]));
    preference.setDefaultValue(String.valueOf(Preferences.VALUE_DEFAULT_SIM));
    preference.setSummary(preference.getEntry());
}
 
开发者ID:avast,项目名称:sms-ticket,代码行数:20,代码来源:SettingsFragment.java


示例10: getActiveSubscriptionInfo

import android.telephony.SubscriptionInfo; //导入依赖的package包/类
public Optional<SubscriptionInfoCompat> getActiveSubscriptionInfo(int subscriptionId) {
  if (Build.VERSION.SDK_INT < 22) {
    return Optional.absent();
  }

  SubscriptionInfo subscriptionInfo = SubscriptionManager.from(context).getActiveSubscriptionInfo(subscriptionId);

  if (subscriptionInfo != null) {
    return Optional.of(new SubscriptionInfoCompat(subscriptionId, subscriptionInfo.getDisplayName()));
  } else {
    return Optional.absent();
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:14,代码来源:SubscriptionManagerCompat.java


示例11: sendSms

import android.telephony.SubscriptionInfo; //导入依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP_MR1)
private void sendSms(final int which,String phone,String context) {
    SubscriptionInfo sInfo = null;

    final SubscriptionManager sManager = (SubscriptionManager) getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);

    List<SubscriptionInfo> list = sManager.getActiveSubscriptionInfoList();

    if (list.size() == 2) {
        // 双卡
        sInfo = list.get(which);
    } else {
        // 单卡
        sInfo = list.get(0);
    }

    if (sInfo != null) {
        int subId = sInfo.getSubscriptionId();
        SmsManager manager = SmsManager.getSmsManagerForSubscriptionId(subId);

        if (!TextUtils.isEmpty(phone)) {
            ArrayList<String> messageList =manager.divideMessage(context);
            for(String text:messageList){
                manager.sendTextMessage(phone, null, text, null, null);
            }
            Toast.makeText(this, "信息正在发送,请稍候", Toast.LENGTH_SHORT)
                    .show();
        } else {
            Toast.makeText(this, "无法正确的获取SIM卡信息,请稍候重试",
                    Toast.LENGTH_SHORT).show();
        }
    }
}
 
开发者ID:GHBlade,项目名称:Msgs,代码行数:34,代码来源:MainActivity.java


示例12: getActiveDataSubscriptionInfo

import android.telephony.SubscriptionInfo; //导入依赖的package包/类
/**
 * Get information about the SIM that is currently used for data
 * @return info or NULL if there is no active sim or the active sim cannot be detected
 */
public ActiveDataSubscriptionInfo getActiveDataSubscriptionInfo() {
    SubscriptionInfo activeSubscription;
    ActiveDataSubscriptionInfo info = new ActiveDataSubscriptionInfo();
    if (subscriptionManager.getActiveSubscriptionInfoCount() > 1) {
        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            int dataSubscriptionId = subscriptionManager.getDefaultDataSubscriptionId();
            activeSubscription = subscriptionManager.getActiveSubscriptionInfo(dataSubscriptionId);
        }
        else {
            activeSubscription = null;
        }
    }
    else if (subscriptionManager.getActiveSubscriptionInfoCount() == 1) {
        activeSubscription = subscriptionManager.getActiveSubscriptionInfoList().get(0);
    }
    else {
        activeSubscription = null;
    }

    if (activeSubscription != null) {
        //fill info from this
        info.setCountry(activeSubscription.getCountryIso());
        String simOperator = activeSubscription.getMcc() + "-" + String.format("%02d", activeSubscription.getMnc());
        info.setSimOperator(String.valueOf(simOperator));
        info.setSimOperatorName(activeSubscription.getCarrierName().toString());
        info.setDisplayName(activeSubscription.getDisplayName().toString());
        info.setSimCount(subscriptionManager.getActiveSubscriptionInfoCount());
        return info;
    }

    return null;
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:37,代码来源:SubscriptionInfoHelper.java


示例13: getSubscriptions

import android.telephony.SubscriptionInfo; //导入依赖的package包/类
@Nullable
public static List<SubscriptionInfo> getSubscriptions(Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
        SubscriptionManager sm = SubscriptionManager.from(context);
        return sm.getActiveSubscriptionInfoList();
    }

    return null;
}
 
开发者ID:kaliturin,项目名称:BlackList,代码行数:10,代码来源:SubscriptionHelper.java


示例14: getCurrentSubscriptionId

import android.telephony.SubscriptionInfo; //导入依赖的package包/类
/**
 * @return id of the current subscription (id of SIM)
 */
@Nullable
public static Integer getCurrentSubscriptionId(Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
        SubscriptionInfo info = getCurrentSubscription(context);
        if (info != null) return info.getSubscriptionId();
    }

    return null;
}
 
开发者ID:kaliturin,项目名称:BlackList,代码行数:13,代码来源:SubscriptionHelper.java


示例15: getCurrentSubscriptionName

import android.telephony.SubscriptionInfo; //导入依赖的package包/类
@Nullable
public static String getCurrentSubscriptionName(Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
        SubscriptionInfo info = getCurrentSubscription(context);
        if (info != null) return info.getDisplayName().toString();
    }

    return null;
}
 
开发者ID:kaliturin,项目名称:BlackList,代码行数:10,代码来源:SubscriptionHelper.java


示例16: getCurrentSubscription

import android.telephony.SubscriptionInfo; //导入依赖的package包/类
@Nullable
public static SubscriptionInfo getCurrentSubscription(Context context) {
    Integer subscriptionId = Settings.getIntegerValue(context, Settings.SIM_SUBSCRIPTION_ID);
    if (subscriptionId != null && subscriptionId >= 0) {
        return getSubscriptionById(context, subscriptionId);
    }

    return null;
}
 
开发者ID:kaliturin,项目名称:BlackList,代码行数:10,代码来源:SubscriptionHelper.java


示例17: getSubscriptionById

import android.telephony.SubscriptionInfo; //导入依赖的package包/类
@Nullable
public static SubscriptionInfo getSubscriptionById(Context context, int subscriptionId) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
        List<SubscriptionInfo> list = getSubscriptions(context);
        if (list != null) {
            for (SubscriptionInfo info : list) {
                if (info.getSubscriptionId() == subscriptionId) {
                    return info;
                }
            }
        }
    }

    return null;
}
 
开发者ID:kaliturin,项目名称:BlackList,代码行数:16,代码来源:SubscriptionHelper.java


示例18: getName

import android.telephony.SubscriptionInfo; //导入依赖的package包/类
@Nullable
public static String getName(SubscriptionInfo info) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1 && info != null) {
        return info.getDisplayName().toString();
    }
    return null;
}
 
开发者ID:kaliturin,项目名称:BlackList,代码行数:8,代码来源:SubscriptionHelper.java


示例19: getId

import android.telephony.SubscriptionInfo; //导入依赖的package包/类
@Nullable
public static Integer getId(SubscriptionInfo info) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1 && info != null) {
        return info.getSubscriptionId();
    }
    return null;
}
 
开发者ID:kaliturin,项目名称:BlackList,代码行数:8,代码来源:SubscriptionHelper.java


示例20: smsSubscriptionManager

import android.telephony.SubscriptionInfo; //导入依赖的package包/类
@Test
public void smsSubscriptionManager() throws Exception {
    Context context = InstrumentationRegistry.getTargetContext();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
        List<SubscriptionInfo> list = SubscriptionHelper.getSubscriptions(context);
        if (list != null) {
            int subscriptionId = -1;
            for (SubscriptionInfo info : list) {
                Log.d("TEST_SmsManager", info.toString());
                subscriptionId = info.getSubscriptionId();
            }
            assertTrue(subscriptionId >= 0);
        }
    }
}
 
开发者ID:kaliturin,项目名称:BlackList,代码行数:16,代码来源:ExampleInstrumentedTest.java



注:本文中的android.telephony.SubscriptionInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PathIsNotEmptyDirectoryException类代码示例发布时间:2022-05-21
下一篇:
Java UserNeighborhood类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap