Is there a way to access an activity while the device screen is locked?

mistermentality

Active Member
Licensed User
Longtime User
I want to use the wifi library in a service but cannot so I placed it in an activity and call the routine that deals with it by unpausing the activity.

Unfortunately even though I only want to use the wifi library, I cannot if the screen is locked.Is there a way around this, maybe a way to access a routine in an activity that does not need the screen to be unlocked?

Dave
 

agraham

Expert
Licensed User
Longtime User
There should be no problem doing in a Service anything that an Activity can do - except interact wiith the user via the UI.

EDIT :- Ah! I see that the AbWiFi object in the WiFi library is declared as an Activity object. This is not necessary as it does not interact with UI elements but this prevents its use in a Service. It needs recompilation by the author as a non-Activity object.
 
Last edited:
Upvote 0

mistermentality

Active Member
Licensed User
Longtime User
There should be no problem doing in a Service anything that an Activity can do - except interact wiith the user via the UI.

EDIT :- Ah! I see that the AbWiFi object in the WiFi library is declared as an Activity object. This is not necessary as it does not interact with UI elements but this prevents its use in a Service. It needs recompilation by the author as a non-Activity object.

Thank you for the explanation. Oddly enough I did manage to find a way to use the wifi library in a service, eventually, but I cannot seem to get a service to send a text message with gps data while screen is locked so this is my next challenge :)

If it helps anyone else the way I got it to work was as follows (though I only use the gsm triangulation ability so not sure if the other aspects of it will work).

In the sub I want to access the wifi data from I used the code:

B4X:
Dim myWifi2 As ABWifi
Dim ResLocation2 As ABFoundLocation
Dim r2 As Boolean
   r2 = myWifi2.ABGetLocation("myWifi2")
   ResLocation2 = myWifi2.ABGetFoundLocation()

And then the left the ABGetFoundLocation() sub empty

B4X:
Sub myWifi2_FoundLocation ()

End Sub

But it does work that way :)

Dave
 
Upvote 0
Top