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


Java SmsManager.STATUS_ON_ICC_SENT属性代码示例

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


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

示例1: translateStatus

/**
 * Translates EF_SMS status bits to a status value compatible with SMS AT
 * commands. See TS 27.005 3.1.
 */
private int translateStatus(int status) {
	switch (status & 0x7) {
	case SmsManager.STATUS_ON_ICC_READ:
		return 1;
	case SmsManager.STATUS_ON_ICC_UNREAD:
		return 0;
	case SmsManager.STATUS_ON_ICC_SENT:
		return 3;
	case SmsManager.STATUS_ON_ICC_UNSENT:
		return 2;
	}

	// Default to READ.
	return 1;
}
 
开发者ID:kasbert,项目名称:ATRILD,代码行数:19,代码来源:ATCommandsImpl.java

示例2: send

private void send(final CallbackContext callbackContext, String phoneNumber, String message) {
	SmsManager manager = SmsManager.getDefault();
	final ArrayList<String> parts = manager.divideMessage(message);

	// by creating this broadcast receiver we can check whether or not the SMS was sent
	final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {

		boolean anyError = false; //use to detect if one of the parts failed
		int partsCount = parts.size(); //number of parts to send

		@Override
		public void onReceive(Context context, Intent intent) {
			switch (getResultCode()) {
			case SmsManager.STATUS_ON_ICC_SENT:
			case Activity.RESULT_OK:
				break;
			case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
			case SmsManager.RESULT_ERROR_NO_SERVICE:
			case SmsManager.RESULT_ERROR_NULL_PDU:
			case SmsManager.RESULT_ERROR_RADIO_OFF:
				anyError = true;
				break;
			}
			// trigger the callback only when all the parts have been sent
			partsCount--;
			if (partsCount == 0) {
				if (anyError) {
					callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR));
				} else {
					callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
				}
				cordova.getActivity().unregisterReceiver(this);
			}
		}
	};

	// randomize the intent filter action to avoid using the same receiver
	String intentFilterAction = INTENT_FILTER_SMS_SENT + java.util.UUID.randomUUID().toString();
	this.cordova.getActivity().registerReceiver(broadcastReceiver, new IntentFilter(intentFilterAction));

	PendingIntent sentIntent = PendingIntent.getBroadcast(this.cordova.getActivity(), 0, new Intent(intentFilterAction), 0);

	// depending on the number of parts we send a text message or multi parts
	if (parts.size() > 1) {
		ArrayList<PendingIntent> sentIntents = new ArrayList<PendingIntent>();
		for (int i = 0; i < parts.size(); i++) {
			sentIntents.add(sentIntent);
		}
		manager.sendMultipartTextMessage(phoneNumber, null, parts, sentIntents, null);
	}
	else {
		manager.sendTextMessage(phoneNumber, null, message, sentIntent, null);
	}
}
 
开发者ID:cordova-sms,项目名称:cordova-sms-plugin,代码行数:54,代码来源:Sms.java


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