Meine App benötigt Tracking in Echtzeit, also brauche ich einen Knopf, der alle 5 Sekunden auslösen muss, aber ich habe keine Ahnung, wie es geht. Kannst du mir beibringen wie?Knopf zum Auslösen alle 5 Sekunden
Ich möchte, dass alle 5 Sekunden AsyncTask
ausgelöst wird.
btnStart.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
HashMap postLoc = new HashMap();
postLoc.put("txtLat", tvLat.getText().toString());
postLoc.put("txtLng", tvLong.getText().toString());
postLoc.put("txtOwner", pref.getString("username","").toString());
PostResponseAsyncTask taskLoc = new PostResponseAsyncTask(getActivity(), postLoc,false, new AsyncResponse() {
@Override
public void processFinish(String s) {
Log.d(TAG, tvLat.getText().toString());
Log.d(TAG, tvLong.getText().toString());
Intent i = new Intent(getActivity(),GPS_Service.class);
getActivity().startService(i);
}
});
taskLoc.execute("http://carkila.esy.es/carkila/locationUpdate.php");
}
});
http://stackoverflow.com/questions/6531950/how-to-execute-async-task-wiederholt-nach-fixed-time-intervals –