I have an error when I try to send my location data using my android to my sql server. I used a service, httpclient and a loop-thread to send my data to my server. I believe that my network speed is slow. Here is the code:
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// TODO Auto-generated method stub
if (!isRunning) {
mythread.start();
isRunning = true;
}
sp = PreferenceManager.getDefaultSharedPreferences(this);
return super.onStartCommand(intent, flags, startId);
}
public void accessWebPage() {
try {
busID = sp.getString("busNumber", "");
ipadd = sp.getString("ipAddress", "");
response = httpclient.execute(new HttpGet("http://" + ipadd
+ link+"?msg=ID" + busID + "%20TM" + time
+ "%20DT" + date + "%20LT" + latitude + "%20LN" + longitude
+ "%20AT" + altitude + "%20SP" + speed + "%20CO" + course));
} catch (ClientProtocolException e) {
} catch (IOException e) {
} catch (Exception e) {
}
}
class MyThread extends Thread {
static final long DELAY = 3000;
@Override
public void run() {
while (isRunning) {
try {
accessWebPage();
Thread.sleep(DELAY);
} catch (InterruptedException e) {
}
}
}
}