'Android' Interval from Fused Location API is not correct -
i want location information on interval set.
but doesn't come have expected.
below code.
on activitya
public void onconnected(@nullable bundle bundle) {
$locationrequestinterval = 3000; if (activitycompat.checkselfpermission(this, android.manifest.permission.access_fine_location) != packagemanager.permission_granted) { } pendingintent pendingintent = pendingintent.getservice(this, 0, new intent(this, hardwarehandler.class), pendingintent.flag_update_current); locationrequest locationrequest = locationrequest.create(); locationrequest.setpriority(locationrequest.priority_high_accuracy).setinterval($locationrequestinterval); locationservices.fusedlocationapi.requestlocationupdates($googleapiclient, locationrequest, pendingintent);
}
on activityb
protected void onhandleintent(intent _intent) {
if (locationresult.hasresult(_intent)) { locationresult locationresult = locationresult.extractresult(_intent); try { intent intent = new intent(this, sqlitehandler.class); intent.putextra("category", "hh(location)"); intent.putextra("timestamp", new simpledateformat("yyyy.mm.dd_hh.mm.ss").format(new date(system.currenttimemillis()))); intent.putextra("latitude", locationresult.getlastlocation().getlatitude()); intent.putextra("longitude", locationresult.getlastlocation().getlongitude()); pendingintent pendingintent = pendingintent.getservice(this, 0, intent, pendingintent.flag_update_current); pendingintent.send(); } catch (pendingintent.canceledexception e) { e.printstacktrace(); } }
}
wiki
Comments
Post a Comment