如何像UPI一样创建应用程序?

时间:2017-11-20 16:48:41

标签: android

UPI android app如何获取SIM卡操作员名称并使用选定的SIM卡发送消息。

我正在使用Subscription Manager获取运营商名称。我的代码获取运营商名称是

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

for (int i = 0; i < subscriptionInfos.size(); i++) 
{
    carrierNames.add(subscriptionInfos.get(i).getCarrierName().toString());
    subscriptionId.add(subscriptionInfos.get(i).getSubscriptionId());
}

1 个答案:

答案 0 :(得分:0)

尝试

TelephonyManager telephonyManager= (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
String carrierName = telephonyManager.getNetworkOperatorName();

对于发送短信,您可以执行以下操作:

PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
new Intent(this, class), 0);                
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNumber, null, " <your message>", pendingIntent, null);