LHerskind / PokemonPositionFaker

A module for the xposed framework used for simulation walking in Pokemon GO
4 stars 1 forks source link

App Life Cycle Issue #11

Open maxime-poulain opened 8 years ago

maxime-poulain commented 8 years ago

Hello,

when the app is getting stopped or even destroyed by the android system, if you try opening it up, for something like putting a new location to walk to , it will TOTALY restart. Thus your characther (I mean mEndLock) is again located at the location you are at.

I don't remember correctly Android app life cycle but I think everything has to do to with the onRestart & onStop methond from Activity class.

I mean until your application is not destroyed by the user IT SHOULD not reset default value. Would overriding onStop() method to save the endLoc in the sharedpreference prevent this ?

DUnno if I could make myself clear,

cheers mate I love your work :D .

Will try helping ; gonna clone by tmr and pull request at least french translations.

LHerskind commented 8 years ago

Well this should be fixable pretty easy, i could just make it catch the latest coordinates and then move to that position when u start the app again? Sound like an idea for you?

@Override public void onPause() { super.onPause(); mLatitude = Double.parseDouble(sharedPreferences.getString("latitude", "420")); mLongtitude = Double.parseDouble(sharedPreferences.getString("longtitude", "420"));

maxime-poulain commented 8 years ago

That's one way to go indeed.

Dunno if you should save the location onPause() or onStop().

I think saving the location on the onPause() ( commiting to the shared pref the currend endLoc) and restoring the loc on onStart() seems good , I Think.

You might also add a switch for user that do not care about that. However I don't see why anyone would like that :P.

Olaf3210 commented 8 years ago

The proper way to fix that is to use a service to store the position (and handle the movement), as services keep running as long as other apps need then. This will also fix #2 as no shared preferences will be needed anymore. I've implemented it, but I need to cleanup my code and merge the recent commits before posting a PR.

maxime-poulain commented 8 years ago

@Olaf3210

you are right a service in the background get less likely killed by the system. That is exactly we need: as we want to keep the same coordinates from the first start.