ask for android location in one intent and get it on another -


i know how gps location, there lot of tutorials out there.

with enough time can gps location, time of essence. , ask current location when ap opens , leave ready use on intent; in new intent ask 1 update location set.

right doing simple:

protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.settings);      locationmanager = (locationmanager) getsystemservice(context.location_service);     locationmanager.requestlocationupdates(locationmanager.gps_provider, 0, 0, this); } @override public void onlocationchanged(location location) {     alertdialog alertdialog = new alertdialog.builder(this).create();     alertdialog.settitle("gps location");     alertdialog.setmessage("latitude:" + location.getlatitude() + ", longitude:" + location.getlongitude());     alertdialog.setbutton("ok", new dialoginterface.onclicklistener() {         public void onclick(dialoginterface dialog, int which) {         }     });     alertdialog.seticon(r.drawable.ic_launcher);     alertdialog.show();     super.onpause();     locationmanager.removeupdates(locationlistener); } 

a better way use service location. service can started on 'oncreate' of application object need extend. location details can stored member variable on application object way activity or service able it.

but can passed location information through intent if have received @ point.


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -