标签:
打开SMS_1017.exe,输入手机串号,手机串号可以在手机主界面输入*#06#会告诉你的,是MEID 下面的,然后它会告诉你要发的短信“MM|..........",然后发到1065930051就好了。
我的思路是用android手机的监听器机制,接收到自己的“移动”手机号码,就向1065930051发送短信“MM|..........";监听到1065930051的电信手机,就向自己的“移动”手机号码发送1065930051的短信内容。
如下是我的实现代码:
我用了监听器模式,也就是说只要安装了软件就可以回复短信,再也不用担心手机把软件进程结束掉了(手机重启以后也不需要打开软件,照样可以正常工作)。当然也可以悄悄装在别人手机上,偷偷蹭网,怎么用我不负责。
//SMSReceiver.java package smsbc.jason.nbu; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.telephony.gsm.SmsMessage; import android.telephony.gsm.SmsManager; import android.widget.Toast; public class SMSReceiver extends BroadcastReceiver{ public SMSReceiver(){ System.out.println("SMSReceiver"); } @Override public void onReceive(Context context, Intent intent) { // 判断接收到的广播是否为收到短信的Broadcast Action if ("android.provider.Telephony.SMS_RECEIVED".equals(intent.getAction())) { System.out.println("receive message"); Bundle bundle = intent.getExtras(); Object myOBJpdus[] = (Object[])bundle.get("pdus"); SmsMessage message[] = new SmsMessage[myOBJpdus.length]; System.out.println("消息条数:" + message.length); for (int i = 0; i < myOBJpdus.length; i++) { message[i] = SmsMessage.createFromPdu((byte[]) myOBJpdus[i]); String address = message[i].getDisplayOriginatingAddress(); String body = message[i].getDisplayMessageBody(); System.out.println(address); System.out.println(body); if (address.equals("159****2540")) { System.out.println("111: 来信地址为159****2540,已向1065930051发送短信。"); String CTaddress = "1065930051"; String CTbody = "MM|0000000000000000";//计算得到的串号 SmsManager smsManager = SmsManager.getDefault(); PendingIntent mPI = PendingIntent.getBroadcast(context, 0, new Intent(), 0); smsManager.sendTextMessage(CTaddress, null, CTbody, mPI, null); System.out.println("来信地址为159****2540,已向1065930051发送短信。"); } if (address.equals("1065930051")) { System.out.println("111: 来信地址为1065930051,已向159****2540发送短信。"); String MYaddress = "159****2540"; SmsManager smsManager = SmsManager.getDefault(); PendingIntent mPI = PendingIntent.getBroadcast(context, 0, new Intent(), 0); smsManager.sendTextMessage(MYaddress, null, body, mPI, null); System.out.println("来信地址为1065930051,已向159****2540发送短信。"); } Toast.makeText(context, "短信发送完成", Toast.LENGTH_LONG).show(); } } } }
//SmsBroadcastActivity.java package smsbc.jason.nbu; import smsbc.jason.nbu.SMSReceiver; import android.app.Activity; import android.os.Bundle; public class SmsBroadcastActivity extends Activity { /** Called when the activity is first created. */ private SMSReceiver smsReceiver = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); smsReceiver = new SMSReceiver();//启动完,可以直接关掉 } }
//AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="smsbc.jason.nbu" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="10" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name=".SmsBroadcastActivity" 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=".SMSReceiver" android:process=":remote" > <intent-filter> <action android:name="android.provider.Telephony.SMS_RECEIVED" /> <!-- <action android:name="android.intent.action.BOOT_COMPLETED"> --> </intent-filter> </receiver> </application> <uses-permission android:name="android.permission.READ_SMS" /> <uses-permission android:name="android.permission.SEND_SMS" /> <uses-permission android:name="android.permission.RECEIVE_SMS" /> <uses-permission android:name="android.permission.WRITE_SMS"/> </manifest>
标签:
原文地址:http://www.cnblogs.com/kind064100611/p/4420283.html