中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

Android 發(fā)送短信程序

2018-07-20    來(lái)源:open-open

容器云強(qiáng)勢(shì)上線!快速搭建集群,上萬(wàn)Linux鏡像隨意使用
mButton1.setOnClickListener(new Button.OnClickListener() {

	@Override
	public void onClick(View v) {
		/* 由EditText1取得簡(jiǎn)訊收件人電話 */
		String strDestAddress = mEditText1.getText().toString();
		/* 由EditText2取得簡(jiǎn)訊文字內(nèi)容 */
		String strMessage = mEditText2.getText().toString();
		/* 建構(gòu)一取得default instance的 SmsManager對(duì)象 */
		SmsManager smsManager = SmsManager.getDefault();
		// TODO Auto-generated method stub
		/* 檢查收件人電話格式與簡(jiǎn)訊字?jǐn)?shù)是否超過(guò)70字符 */
		if (isPhoneNumberValid(strDestAddress) == true
				&& iswithin70(strMessage) == true) {
			try {
				/*
				 * 兩個(gè)條件都檢查通過(guò)的情況下,發(fā)送簡(jiǎn)訊 *
				 * 先建構(gòu)一PendingIntent對(duì)象并使用getBroadcast()方法進(jìn)行Broadcast *
				 * 將PendingIntent,電話,簡(jiǎn)訊文字等參數(shù)傳入sendTextMessage()方法發(fā)送簡(jiǎn)訊
				 */
				PendingIntent mPI = PendingIntent.getBroadcast(
						EX05_03.this, 0, new Intent(), 0);
				smsManager.sendTextMessage(strDestAddress, null,
						strMessage, mPI, null);
			} catch (Exception e) {
				e.printStackTrace();
			}
			Toast.makeText(EX05_03.this, "送出成功!!", Toast.LENGTH_SHORT)
					.show();
			mEditText1.setText("");
			mEditText2.setText("");
		}
		/* 電話格式與簡(jiǎn)訊文字不符合條件時(shí),使用Toast告知用戶檢查 */
		else {
			/* 電話格式不符 */
			if (isPhoneNumberValid(strDestAddress) == false) {
				/* 且字?jǐn)?shù)超過(guò)70字符 */
				if (iswithin70(strMessage) == false) {
					Toast.makeText(EX05_03.this,
							"電話號(hào)碼格式錯(cuò)誤+短信內(nèi)容超過(guò)70字,請(qǐng)檢查!!",
							Toast.LENGTH_SHORT).show();
				} else {
					Toast.makeText(EX05_03.this, "電話號(hào)碼格式錯(cuò)誤,請(qǐng)檢查!!",
							Toast.LENGTH_SHORT).show();
				}
			}
			/* 字?jǐn)?shù)超過(guò)70字符 */
			else if (iswithin70(strMessage) == false) {
				Toast.makeText(EX05_03.this, "短信內(nèi)容超過(guò)70字,請(qǐng)刪除部分內(nèi)容!!",
						Toast.LENGTH_SHORT).show();
			}
		}
	}
});

標(biāo)簽: isp

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請(qǐng)聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請(qǐng)與原作者聯(lián)系。

上一篇:Android獲取當(dāng)前手機(jī)的電話號(hào)碼

下一篇:Android圖片異步加載