當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。