Friends, Am able to fetch the latitude and longitude from SqliteDb to place a marker in google Map respectively. But my problem is 1. I want to draw a route from current location to the latitude and longitude fetched from Sqlite Db 2. The db values of Latitude and Longitude will be changed every 2 minutes and i want to change the place in marker accordingly and also route between the updated values and current location.
I have tried running the below code. It runs perfect in Main class but when I tried using thread it fails and since used timer for the same.
protected void mLocActivity() {
db.open();
class preciLoc extends TimerTask{
@Override
public void run() {
Cursor cr = db.fetchone(sLoc, "pos_mark", tblName, "pho", null, null);
if(cr.getCount()>0){
sLat = cr.getString(cr.getColumnIndex("lat"));
sLon = cr.getString(cr.getColumnIndex("lon"));
}
LatLng orgLoc = new LatLng(mLatitude,mLongitude);
LatLng desCur = new LatLng(Double.parseDouble(sLat), Double.parseDouble(sLon));
String url = getDirectionsUrl(orgLoc, desCur);
DownloadTask downloadTask = new DownloadTask();
downloadTask.execute(url);
rMap.moveCamera(CameraUpdateFactory.newLatLng(latLng))
CameraPosition camPos1 = new CameraPosition.Builder()
.target(destCurr).zoom(15).bearing(90).tilt(30).build();
rMap.animateCamera(CameraUpdateFactory
.newCameraPosition(camPos1));
drawMarker(desCur);
}
}
Timer timer = new Timer();
timer.schedule(new preciLoc(), 50000);
}