Update # 2 My initial question was solved by the kindness of the two people who answered. Apparently I have to start a new question for this fact that the resulting code, when it runs, can not stop the GPS. But no error now I see this must be marked if I knew how to solve as: -.)
update
I have to "work" comment The code for Thanksgiving is the problem that it does not do that which is supposed to be doing it. It is working that there is no error in it.
To make it work, I added globally at the top of this activity.
Protected Location Lister; Safe Location Manager LM; and this OnPause code is used
@Override protected zero onPause (if {lm = null!) {Lm.removeUpdates (LL ); } Ll = null; Lm = null; Super.onPause (); } Everything compiled and runs on the phone has been displayed to me GPS locations. The trouble is to get the GPS to close the goal so that the battery will not die after leaving the application. But depending on GPS I see that this is a common complaint and I have not seen the answer. I thought lm.removeupdates (ll) was a solution but it is not working.
--------------- Original post -------- ----------------- < / P>
I want to add some onion code to stop my GPS updates. I have stackoverflow tired of code from both questions and answers, at least a dozen examples and all the errors in eclipse
My GPS code (it works fine) is here. Override public zeroes on @ create (bundle saved instainstate) {super. Nc (saved instant state); SetContentView (R.layout.activity_main); TextLat = (TextView) Find ViewById (R.id.textLat); Find Text Long = (TextView) VVBIID (RdextLog); TextTimex = (TextView) SearchVBIID (RID. Textimix); LocationManager lm = (LocationManager) getSystemService (context.LOCATION_SERVICE); LocationList ll = new mylocationlistener (); Lm.requestLocationUpdates (LocationManager.GPS_PROVIDER, 0, 0, ll); } Class mylocationlistener appliesLocationListener {@Override Public Zero onLocationChanged (location location) {if (location = null!) {Double benny = location.getLatitude (); Double PLF = location.get lagetid (); Long pTime = location.getTime (); Decimalf df = new substitute ("######"); TextLat.setText (df.format); TextLong.setText (df.format (Plong)); TextTimex.setText (Long.toString (pTime)); //textTimex.setText(Long.toString (pTime)); //textTimex.setText(df.format(pLong)); }} @Override public void onProviderDisabled (String provider) {// TODO Auto-generated method stub} @Override public void onProviderEnabled (String provider) {// TODO Auto-generated method stub} @Override public void onStatusChanged (String provider, int position, bundled extras) {// Tudo Auto-generated method stub}} I am using code examples on the web and does not work with them at a Prevent public void on @override () {lm.removeUp Dates (locationListener); Super.onPause (); } It does not really matter what I say LM, it gives an error that he could not solve it. It does not matter which example code I use, none of them is error-free.
I want to do something very stupid ...
declare LocationListener globally (as out of the onCreate method of activity): will locationListener; Override public null on @reate (bundle saved instainstate) {super.naught (savedinstenstate); SetContentView (R.layout.activity_main); //// Your code ... ll = new mylocationlistener (); //// Your code ..} @ Override Protected Zero at POS () {Super.Ponose (); // TODO auto generated method stub System.out.println ("onPause () an intrat"); If (LM! = NULL) {lm.removeUpdates (ll); } Ll = null; Lm = null; }
Comments
Post a Comment