Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 7    Views: 66

Patrickmotox
Aspiring developer
Profile
Posts: 89
Reg: Dec 10, 2013
Cameron Park, C...
7,090
04/14/14 12:35 PM (10 years ago)

Location Map error on exit

I have found that when using the location map in Android, that if the map is open and you close the app via the menu "Quit App", you get the error "Unfortunately <program name> has stopped". If it is a released app you also have two buttons, Report and OK. with a dev app you only have the Ok button. I just reviewed a released app and it is doing the same thing my apps do with Location Map. Has anyone else run into this? Or know the solution to fix....? kind regards Patrick McGoey
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
04/15/14 06:54 AM (10 years ago)
Reposted from an off topic response in Alan's thread (sorry Alan Mac!): I'm just taking a stab at this; it may not matter. but I noticed in the BT_screen_map.java file there is no handler for onPause, onStop, or any of that. Only 'onDestroy'. It's possible that the 'quit' command kinda catches the map off guard. Try taking the same methods in 'onDestroy' and add them to an 'onStop' method, like… public void onStop() { super.onStop(); MapFragment destroyMap = (MapFragment)getFragmentManager().findFragmentById(R.id.mapView); if(destroyMap != null){ getFragmentManager().beginTransaction().remove(destroyMap).commit(); } } I'm just wondering if the map isn't quitting before the app, and gets caught 'by surprise'… It may 'not' work. But it's a guess. Cheers! -- Smug
 
Patrickmotox
Aspiring developer
Profile
Posts: 89
Reg: Dec 10, 2013
Cameron Park, C...
7,090
like
04/15/14 09:29 AM (10 years ago)
I was thinking the along the same lines and am doing some experimenting....... Smug. So far so good. With this plugin there is a onCreateView and onDestroyView. The code to remove the fragment is in the onDestroyView. I took your suggestion and added in the onStop with the code to remove the Fragment, and then removed it from the onDestroyView. It works. woo hoo... I you weren't a man, I would kiss you. Well maybe I would anyway.. Hee hee.....
 
LeonG
Apple Fan
Profile
Posts: 694
Reg: Nov 08, 2011
Hamburg
17,740
like
05/08/14 06:06 AM (10 years ago)
I have the same problem. It also happens if I click on my menu tab for map again if the map is already displayed. Adding the onStop like Smug said does not change anything. On Android 3.0 and self hosted. Help would be much appreciated. Regards Leon
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
05/09/14 05:51 AM (10 years ago)
Leon, It may exhibit different behavior on a tabbed app as opposed to a single view kind of app. you may want to experiment with it on 'onStop', 'onPause' and so on, just to see if it helps/hurts/makes no difference. fingers crossed… Cheers! -- Smug
 
LeonG
Apple Fan
Profile
Posts: 694
Reg: Nov 08, 2011
Hamburg
17,740
like
05/09/14 12:09 PM (10 years ago)
still not quite sure if I swap your code or add it to the existing parts?
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
05/09/14 03:36 PM (10 years ago)
Experiment… try both :) I'm not saying it's a solution… but it's an option to try… Cheers! -- Smug
 
appsolutely
Aspiring developer
Profile
Posts: 72
Reg: Jan 05, 2011
UK
10,070
like
01/26/15 10:47 AM (9 years ago)
Hi All, I'm suffering with these map problems on android too. Having used SmugWimp's directions I have managed to overcome the first 2 issues however I am now up against another. I initially had the problems detailed above on exit and having adjusted the code I now have the problem that if the home button of the handset is pressed or you navigate away from the map by selecting the directions option of a pin, when you return to the app it just shows a black panel where the map should be and you have to refresh the tab by navigating away and then back to show the map again. Is there any way to force the map to refresh when it becomes the front app again? I tried to replicate the code for "public void refreshScreenData" for an onResume but this just stopped the map loading at all (as I kind of expected). I'm not great with code so a little guess work going on. Here is my current map screen java code below: public void onDestroyView() { super.onDestroyView(); BT_debugger.showIt(fragmentName + ":onDestroyView"); MapFragment destroyMap = (MapFragment)getFragmentManager().findFragmentById(R.id.mapView); if(destroyMap != null){ getFragmentManager().beginTransaction().remove(destroyMap).commit(); } } public void onStop() { super.onStop(); MapFragment destroyMap = (MapFragment)getFragmentManager().findFragmentById(R.id.mapView); if(destroyMap != null){ getFragmentManager().beginTransaction().remove(destroyMap).commit(); } } public void onPause() { super.onPause(); MapFragment destroyMap = (MapFragment)getFragmentManager().findFragmentById(R.id.mapView); if(destroyMap != null){ getFragmentManager().beginTransaction().remove(destroyMap).commit(); } } I would really appreciate any help on this! Thanks
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.