当前位置: 首页>>代码示例>>Java>>正文


Java SubscriptionManager.getActiveSubscriptionInfoList方法代码示例

本文整理汇总了Java中android.telephony.SubscriptionManager.getActiveSubscriptionInfoList方法的典型用法代码示例。如果您正苦于以下问题:Java SubscriptionManager.getActiveSubscriptionInfoList方法的具体用法?Java SubscriptionManager.getActiveSubscriptionInfoList怎么用?Java SubscriptionManager.getActiveSubscriptionInfoList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.telephony.SubscriptionManager的用法示例。


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

示例1: onHandleIntent

import android.telephony.SubscriptionManager; //导入方法依赖的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

示例2: fillDualSimList

import android.telephony.SubscriptionManager; //导入方法依赖的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

示例3: sendSms

import android.telephony.SubscriptionManager; //导入方法依赖的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

示例4: getSubscriptions

import android.telephony.SubscriptionManager; //导入方法依赖的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

示例5: prepareSendSms

import android.telephony.SubscriptionManager; //导入方法依赖的package包/类
@Override
public void prepareSendSms() {

    if (view != null && needDialog) {

        view.showLoading();
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {

        SubscriptionManager mSubscriptionManager = SubscriptionManager.from(context);
        subInfoList = mSubscriptionManager.getActiveSubscriptionInfoList();
        if (subInfoList != null && subInfoList.size() > 1) {
            carriersICC.add(0, subInfoList.get(0).getSubscriptionId());
            carriersICC.add(1, subInfoList.get(1).getSubscriptionId());
            carriersNAME.add(0, subInfoList.get(0).getCarrierName().toString());
            carriersNAME.add(1, subInfoList.get(1).getCarrierName().toString());

            view.hideLoading();
            view.renderSimChooserView(context, carriersNAME.get(0), carriersNAME.get(1));

        } else {
            carriersICC.add(0, subInfoList.get(0).getSubscriptionId());
            carriersNAME.add(0, subInfoList.get(0).getCarrierName().toString());
            sendSmsFromSubscriptionIdIndex(0);
        }

    } else {
        sendSmsForOldPhones();
    }
}
 
开发者ID:mahdit83,项目名称:advancedSmsManager,代码行数:32,代码来源:SendSmsPresenterImpl.java

示例6: build

import android.telephony.SubscriptionManager; //导入方法依赖的package包/类
@Override
public RadioGroup build() {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) {
        return getView();
    }
    SubscriptionManager subscriptionManager = (SubscriptionManager) activity.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
    if (null == subscriptionManager) {
        return getView();
    }
    if (subscriptionManager.getActiveSubscriptionInfoCount() < 2) {
        sms.setSubscriptionId(subscriptionManager.getActiveSubscriptionInfoList().get(0).getSubscriptionId());
        return getView();
    }
    getView().setVisibility(View.VISIBLE);
    List<Pair<Integer, String>> simCards = new ArrayList<>();
    for (SubscriptionInfo info: subscriptionManager.getActiveSubscriptionInfoList()) {
        simCards.add(new Pair<>(info.getSubscriptionId(), info.getCarrierName().toString()));
    }
    RadioButton radio1 = getView().findViewById(R.id.radio_sim1);
    RadioButton radio2 = getView().findViewById(R.id.radio_sim2);
    prepareRadioButton(radio1, simCards.get(0));
    prepareRadioButton(radio2, simCards.get(1));
    if (!radio1.isChecked() && !radio2.isChecked()) {
        radio1.setChecked(true);
    }
    return getView();
}
 
开发者ID:yeriomin,项目名称:SmsScheduler,代码行数:28,代码来源:BuilderSimCard.java

示例7: getSubscriptionInfo

import android.telephony.SubscriptionManager; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP_MR1)
public static String getSubscriptionInfo(Context context) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1)
        return "Not supported";
    if (!hasPhoneStatePermission(context))
        return "No permission";

    StringBuilder sb = new StringBuilder();
    SubscriptionManager sm = SubscriptionManager.from(context);
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

    sb.append("Slots ")
            .append(sm.getActiveSubscriptionInfoCount())
            .append('/')
            .append(sm.getActiveSubscriptionInfoCountMax())
            .append("\r\n");

    List<SubscriptionInfo> subscriptions = sm.getActiveSubscriptionInfoList();
    if (subscriptions != null)
        for (SubscriptionInfo si : subscriptions)
            sb.append("SIM ")
                    .append(si.getSimSlotIndex() + 1)
                    .append('/')
                    .append(si.getSubscriptionId())
                    .append(' ')
                    .append(si.getCountryIso())
                    .append('/')
                    .append(si.getMcc()).append(si.getMnc())
                    .append(' ')
                    .append(si.getCarrierName())
                    .append(si.getDataRoaming() == SubscriptionManager.DATA_ROAMING_ENABLE ? " R" : "")
                    .append("\r\n");

    if (sb.length() > 2)
        sb.setLength(sb.length() - 2);

    return sb.toString();
}
 
开发者ID:ruibar,项目名称:android-protwall,代码行数:39,代码来源:Util.java

示例8: getNetworkOperators

import android.telephony.SubscriptionManager; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:greenhub-project,项目名称:batteryhub,代码行数:35,代码来源:Phone.java

示例9: getConstants

import android.telephony.SubscriptionManager; //导入方法依赖的package包/类
@Override
public Map<String, Object> getConstants() {

  final Map<String, Object> constants = new HashMap<>();

  try {
    TelephonyManager telManager = (TelephonyManager) this.reactContext.getSystemService(Context.TELEPHONY_SERVICE);

    SubscriptionManager manager = (SubscriptionManager) this.reactContext.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
    List<SubscriptionInfo> subscriptionInfos = manager.getActiveSubscriptionInfoList();

    int sub = 0;
    for (SubscriptionInfo subInfo : subscriptionInfos) {
      CharSequence carrierName = subInfo.getCarrierName();
      String countryIso        = subInfo.getCountryIso();
      int dataRoaming          = subInfo.getDataRoaming();  // 1 is enabled ; 0 is disabled
      CharSequence displayName = subInfo.getDisplayName();
      String iccId             = subInfo.getIccId();
      int mcc                  = subInfo.getMcc();
      int mnc                  = subInfo.getMnc();
      String number            = subInfo.getNumber();
      int simSlotIndex         = subInfo.getSimSlotIndex();
      int subscriptionId       = subInfo.getSubscriptionId();
      boolean networkRoaming   = telManager.isNetworkRoaming();
      String deviceId          = telManager.getDeviceId(simSlotIndex);
      //String deviceId          = telManager.getImei(simSlotIndex) || telManager.getMeid(simSlotIndex);

      constants.put("carrierName" + sub, carrierName.toString());
      constants.put("displayName" + sub, displayName.toString());
      constants.put("countryCode" + sub, countryIso);
      constants.put("mcc" + sub, mcc);
      constants.put("mnc" + sub, mnc);
      constants.put("isNetworkRoaming" + sub, networkRoaming);
      constants.put("isDataRoaming"    + sub, (dataRoaming == 1));
      constants.put("simSlotIndex"     + sub, simSlotIndex);
      constants.put("phoneNumber"      + sub, number);
      constants.put("deviceId"         + sub, deviceId);
      constants.put("simSerialNumber"  + sub, iccId);
      constants.put("subscriptionId"   + sub, subscriptionId);
      sub++;
    }
  } catch (Exception e) {
    e.printStackTrace();
  }

  return constants;
}
 
开发者ID:pocesar,项目名称:react-native-sim-data,代码行数:48,代码来源:RNSimDataModule.java

示例10: getSubscriptionInfo

import android.telephony.SubscriptionManager; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP_MR1)
public static String getSubscriptionInfo(Context context) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1)
        return "Not supported";
    if (!hasPhoneStatePermission(context))
        return "No permission";

    StringBuilder sb = new StringBuilder();
    SubscriptionManager sm = SubscriptionManager.from(context);

    sb.append("Slots ")
            .append(sm.getActiveSubscriptionInfoCount())
            .append('/')
            .append(sm.getActiveSubscriptionInfoCountMax())
            .append("\r\n");

    int dataid = -1;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
        dataid = SubscriptionManager.getDefaultDataSubscriptionId();

    int voiceid = -1;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
        voiceid = SubscriptionManager.getDefaultVoiceSubscriptionId();

    List<SubscriptionInfo> subscriptions = sm.getActiveSubscriptionInfoList();
    if (subscriptions != null)
        for (SubscriptionInfo si : subscriptions)
            sb.append("SIM ")
                    .append(si.getSimSlotIndex() + 1)
                    .append('/')
                    .append(si.getSubscriptionId())
                    .append(' ')
                    .append(si.getCountryIso())
                    .append('/')
                    .append(si.getMcc()).append(si.getMnc())
                    .append(' ')
                    .append(si.getCarrierName())
                    .append(si.getSubscriptionId() == dataid ? " D" : "")
                    .append(si.getSubscriptionId() == voiceid ? " V" : "")
                    .append(si.getDataRoaming() == SubscriptionManager.DATA_ROAMING_ENABLE ? " R" : "")
                    .append("\r\n");

    if (sb.length() > 2)
        sb.setLength(sb.length() - 2);

    return sb.toString();
}
 
开发者ID:miankai,项目名称:MKAPP,代码行数:48,代码来源:Util.java

示例11: getSubscriptionInfo

import android.telephony.SubscriptionManager; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP_MR1)
public static String getSubscriptionInfo(Context context) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1)
        return "Not supported";
    if (!hasPhoneStatePermission(context))
        return "No permission";

    StringBuilder sb = new StringBuilder();
    SubscriptionManager sm = SubscriptionManager.from(context);

    sb.append("Slots ")
            .append(sm.getActiveSubscriptionInfoCount())
            .append('/')
            .append(sm.getActiveSubscriptionInfoCountMax())
            .append("\r\n");

    int dataid = -1;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
        dataid = sm.getDefaultDataSubscriptionId();

    int voiceid = -1;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
        voiceid = sm.getDefaultVoiceSubscriptionId();

    List<SubscriptionInfo> subscriptions = sm.getActiveSubscriptionInfoList();
    if (subscriptions != null)
        for (SubscriptionInfo si : subscriptions)
            sb.append("SIM ")
                    .append(si.getSimSlotIndex() + 1)
                    .append('/')
                    .append(si.getSubscriptionId())
                    .append(' ')
                    .append(si.getCountryIso())
                    .append('/')
                    .append(si.getMcc()).append(si.getMnc())
                    .append(' ')
                    .append(si.getCarrierName())
                    .append(si.getSubscriptionId() == dataid ? " D" : "")
                    .append(si.getSubscriptionId() == voiceid ? " V" : "")
                    .append(si.getDataRoaming() == SubscriptionManager.DATA_ROAMING_ENABLE ? " R" : "")
                    .append("\r\n");

    if (sb.length() > 2)
        sb.setLength(sb.length() - 2);

    return sb.toString();
}
 
开发者ID:Romascu,项目名称:NoRootFirewall-Custom,代码行数:48,代码来源:Util.java


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