android - Remotely activate GPS function -
i asked question implementation of toast message when gps not enabled. of knew possible.
is possible automatically activate gps function in background.
when remotely activate application in background. can activate the gps phone aswell without other phone reporting user ?
the situation this.
we have project named parentalcontrol application. parent has able track child remotely.
does have suggestion or ideas ... ?
if of anyhelp code i'm using @ moment.
import android.app.activity; import android.content.context; import android.location.location; import android.location.locationlistener; import android.location.locationmanager; import android.os.bundle; import android.widget.textview; import android.widget.toast; public class mainactivity extends activity { textview txtlat; textview txtlong; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); txtlat = (textview) findviewbyid(r.id.txtlat); txtlong = (textview) findviewbyid(r.id.txtlong); locationmanager lm = (locationmanager)getsystemservice(context.location_service); // implementation of toasts if (!lm.isproviderenabled(locationmanager.gps_provider)) { toast toast= toast.maketext(mainactivity.this, " can improve accuracy turning on gps", toast.length_short); toast.show(); } locationlistener ll = new mylocationlistener(); lm.requestlocationupdates(locationmanager.gps_provider, 0, 0, ll); } class mylocationlistener implements locationlistener { @override public void onlocationchanged(location location) { if (location != null) { double plong = location.getlongitude(); double plat = location.getlatitude(); txtlat.settext(double.tostring(plat)); txtlong.settext(double.tostring(plong)); } } @override public void onstatuschanged(string s, int i, bundle bundle) { } @override public void onproviderenabled(string s) { } @override public void onproviderdisabled(string s) { } } }
Comments
Post a Comment