我正在開發一個概念證明應用程序在學校,我需要開發一個簡單的應用程序,讓父母跟蹤孩子的Android設備。我已經想出瞭如何使用GPS來獲取位置更新現在什麼是彌合父母的設備和孩子的設備之間的差距的最佳方式?該應用程序如何知道誰是父母,誰是孩子?最好還是使用getLastKnownLocation(最好)將孩子的數據發送到遠程服務器,然後發送給父母,還是有更簡單的方法來完成此操作?發送位置更新到服務器在Android中
在此先感謝。
2012年3月25日* ** * ** * *更新* ** * ** * ** * ** * ** * ** * ** * *
好吧基於從你們那裏我有PHP代碼的文件
<?php
$thisString = $_POST["action"]; // Variable to receive the request from
echo $thisString;
?>
和我的方法的字符串發送到Web服務使用此代碼的建議
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://kre8tiveinspired.com/android/simpleTest.php");
// This is the data to send
String MyName = **"String Test"**; //any data to send
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("action", MyName));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String response = httpclient.execute(httppost, responseHandler);
//This is the response from a php application
String reverseString = response;
Toast.makeText(this, "response " + reverseString, Toast.LENGTH_LONG).show();
}...
它給我一個說「響應字符串測試」的敬酒。 現在確定它可以工作,但我將如何發送兩個不同的變量,如長和經度。然後接收來自ResponseHandler所兩個不同的變量,當我執行 httpclient.execute(httppost,ResponseHandler所命令。
是的這是一個概念證明,所以我絕對期待偷工減料。你和@broschb的一個問題是如何配置服務器。我有我自己的主機帳戶,使用cPanel。建立接收數據的最佳系統是什麼? – inspired 2012-03-24 04:02:21
任何在PHP或Rails中都可以很好地工作。 基本上,你設置了不同的網頁作爲你的服務器的「API」。您的應用程序將調用不同的網頁(或一個大網頁),其中包含querey中的位置座標或其他內容。 – dcow 2012-03-24 04:30:09
請在我的帖子中查看我的更新 – inspired 2012-03-25 23:34:38