Android Question Problems with sending location when the app is in the background (FusedLocationProvider)

jose luis gudino

Active Member
Licensed User
Longtime User
Hello everyone.
I have a query that worries me.

Which is the exact way to send the location while in the background. In previous times, sending the location was extremely simple. Now I haven't made it.

I used a phone with an old version of android 9 and it worked perfectly. install the same program on a phone with android 11, and it stopped working.

My question is: may or may not send in the background at present?. I have done all the examples and I do not get the solution

Thank you all
 

Magma

Expert
Licensed User
Longtime User
Hi there...

you must add notification... at service
B4X:
    Dim n As NB6
....
'also at..
Sub Service_Create
    Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER
    lock.PartialLock
    If Starter.rp.Check(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION) = False Then
        Log("No permission")
        Return
    End If
....

'hmmm and here...
Sub Service_Start (StartingIntent As Intent)
    Service.StartForeground(1, CreateNotification("..."))   'Hey this gonna keep your app in LIFE... do not forget!!!!! - ofcourse need some manifest too.. :-) check there...
    n.Initialize("default", Application.LabelName,  "LOW").AutoCancel(False).SmallIcon(LoadBitmap(File.DirAssets,"icon.png"))
    n.Build("ShareYourSpot", "This is an application, that shares your current location with other users!", "tag1", Main).Notify(1)
...

Check my Example app ... if helps (free source code)... ShareYourSpot
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
I explain in more detail
Then I think your best option is to create a new thread (you can reference this post too) explaining the problem the way you have do in the last post, and post your code too related to that service and the intent.
Your code should be based in the Erel's example
 
Upvote 0

jose luis gudino

Active Member
Licensed User
Longtime User
Hi there...

you must add notification... at service
B4X:
    Dim n As NB6
....
'also at..
Sub Service_Create
    Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER
    lock.PartialLock
    If Starter.rp.Check(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION) = False Then
        Log("No permission")
        Return
    End If
....

'hmmm and here...
Sub Service_Start (StartingIntent As Intent)
    Service.StartForeground(1, CreateNotification("..."))   'Hey this gonna keep your app in LIFE... do not forget!!!!! - ofcourse need some manifest too.. :-) check there...
    n.Initialize("default", Application.LabelName,  "LOW").AutoCancel(False).SmallIcon(LoadBitmap(File.DirAssets,"icon.png"))
    n.Build("ShareYourSpot", "This is an application, that shares your current location with other users!", "tag1", Main).Notify(1)
...

Check my Example app ... if helps (free source code)... ShareYourSpot
Hello, this option worked perfectly, and when you remove it from the task bar it still works,
Thank you all for providing your help
 
Upvote 0

jose luis gudino

Active Member
Licensed User
Longtime User
Then I think your best option is to create a new thread (you can reference this post too) explaining the problem the way you have do in the last post, and post your code too related to that service and the intent.
Your code should be based in the Erel's example
Thank you Jose for always being attentive to giving me your support
 
Upvote 0
Top