where am i going wrong

Marke

Member
Licensed User
Longtime User
I have an activity (main) which calls a gps activity (gps), previously when I went from main to gps after gps lost focus the gps activity was black. I changed the code moving the drawing of screen items onto activity_resume. Now the activity re creates the screen objects everytime, which i know is the correct process but not the desired reqiuirement.

What I need is the activity to draw screen objects on activity_create, then on resume to display the screen objects without redrawing/re-initiating everytime.

My code is...

Sub Activity_Create(FirstTime As Boolean)

If FirstTime = True Then
' initialize comments are original code
' FillMenu
' GPSLoading
'PopulateList(0,0,"",0)
'ListAttr.Visible =False
End If
End Sub

Sub Activity_Resume
If MeLat = 0 OR MeLon = 0 Then
If GPSLabel.IsInitialized = False Then
initialize
FillMenu
GPSLoading
If MeGPS.GPSEnabled = False Then
ToastMessageShow("Please enable the GPS device.", True)
StartActivity(MeGPS.LocationSettingsIntent) 'Will open the relevant settings screen.
Else
MeGPS.Start(500, 10) 'Listen to GPS with no filters.
Log("GPS start")
GPSTimer.Enabled=True
End If
Else
GPSTimer.Enabled = False
MeGPS.Stop
GPSTimeOut = 0
End If
Else
ListAttr.Invalidate
End If
End Sub

Is this the correct way or is there a better approach?
 

Marke

Member
Licensed User
Longtime User
hi Erel,

so am i understanding I need to re-create the ui everytime the activity is accessed in activity_create. Is there a way of pausing the GPS or is this destroyed also.

also...Does this mean that when an activity looses focus it destroys itself or is it paused as such.

I am now reading "Android Process and activities life cycle" to get this clear in my head!
 
Upvote 0

Marke

Member
Licensed User
Longtime User
thanks for your help, I will have a further read and try a few examples to get this right.
 
Upvote 0

Marke

Member
Licensed User
Longtime User
one final question on this, I have created a couple of sample apps and now get an idea of where I am going wrong. The only thing left is...

In my second (GPS) activity I populate a listview from a json file, I use the back button to switch between (gps and main) activities, how do I (or can I) keep the listview populated in the second activity without having to reload the listview everytime the back button is pressed or the device timesout, is this something the statemanager is able to do?

Thanks for your help on this, I really enjoy the basic4android tool (wish all development tools were like this) and hope my simple questions are not taking to much of your valuable time.
 
Upvote 0

Marke

Member
Licensed User
Longtime User
thanks erel, I like the idea of that. Something I would have never of thought of doing.
 
Upvote 0
Top