2 xwm1993 xwm1993 于 2016.03.29 22:55 提问

联网后如何实现两部手机的远程控制

本人初学Android app 应用开发,现在想做一个app .当两部手机相互关联后,当一部手机丢失后,能一部手机能定位丢失的手机,并实现一些简单的远程控制操作

4个回答

caozhy
caozhy   Ds   Rxr 2016.03.29 23:53

不知道你是学生习作还是真的打算开发这么个软件,偷盗手机的人拿到手机的第一件事就是重新刷机了。最最起码也是拔掉里面的sim卡,根本也就不联网了,你还操作个毛。

deepbluemind
deepbluemind   2016.03.30 06:58

用两个类

第一个service类
public class AndroidLocationServices extends Service {

WakeLock wakeLock;

private LocationManager locationManager;

public AndroidLocationServices() {
// TODO Auto-generated constructor stub
}

@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}

@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();

PowerManager pm = (PowerManager) getSystemService(this.POWER_SERVICE);

wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "DoNotSleep");

// Toast.makeText(getApplicationContext(), "Service Created",
// Toast.LENGTH_SHORT).show();

Log.e("Google", "Service Created");

}

@Override
@Deprecated
public void onStart(Intent intent, int startId) {
// TODO Auto-generated method stub
super.onStart(intent, startId);

Log.e("Google", "Service Started");

locationManager = (LocationManager) getApplicationContext()
        .getSystemService(Context.LOCATION_SERVICE);

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
        5000, 5, listener);

}

private LocationListener listener = new LocationListener() {

@Override
public void onLocationChanged(Location location) {
    // TODO Auto-generated method stub

    Log.e("Google", "Location Changed");

    if (location == null)
        return;

    if (isConnectingToInternet(getApplicationContext())) {
        JSONArray jsonArray = new JSONArray();
        JSONObject jsonObject = new JSONObject();

        try {
            Log.e("latitude", location.getLatitude() + "");
            Log.e("longitude", location.getLongitude() + "");

            jsonObject.put("latitude", location.getLatitude());
            jsonObject.put("longitude", location.getLongitude());

            jsonArray.put(jsonObject);

            Log.e("request", jsonArray.toString());

            new LocationWebService().execute(new String[] {
                    Constants.TRACK_URL, jsonArray.toString() });
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

}

@Override
public void onProviderDisabled(String provider) {
    // TODO Auto-generated method stub

}

@Override
public void onProviderEnabled(String provider) {
    // TODO Auto-generated method stub

}

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
    // TODO Auto-generated method stub

}

};

@Override
public void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();

wakeLock.release();

}

public static boolean isConnectingToInternet(Context _context) {
ConnectivityManager connectivity = (ConnectivityManager) _context
.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity != null) {
NetworkInfo[] info = connectivity.getAllNetworkInfo();
if (info != null)
for (int i = 0; i < info.length; i++)
if (info[i].getState() == NetworkInfo.State.CONNECTED) {
return true;
}

}
return false;

}

}

第二个异步任务类

public class LocationWebService extends AsyncTask {

public LocationWebService() {
// TODO Auto-generated constructor stub
}

@Override
protected Boolean doInBackground(String... arg0) {

ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("location", arg0[1]));

HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(arg0[0]);
HttpParams httpParameters = new BasicHttpParams();

httpclient = new DefaultHttpClient(httpParameters);

try {
    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

    HttpResponse response;
    response = httpclient.execute(httppost);
    StatusLine statusLine = response.getStatusLine();
    if (statusLine.getStatusCode() == HttpStatus.SC_OK) {

        Log.e("Google", "Server Responded OK");

    } else {

        response.getEntity().getContent().close();
        throw new IOException(statusLine.getReasonPhrase());
    }
} catch (Exception e) {
    e.printStackTrace();
}

return null;

}
}

lyhoo163
lyhoo163   Rxr 2016.03.30 06:59

实现联网,运程控件另一台手机。

1、另一台手机,植入木马程序。好听一点点是客户端程序。
2、木马程序运行,并联网。
3、木马程序还要防杀毒软件的封杀。
4、服务器端调用木马程序。

lx624909677
lx624909677   Ds   Rxr 2016.03.29 23:03

能实现定位的前提是,丢失的手机开机并且联网,能给另一端发送信号才行

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!