Android Question Background Task and Intent

Emme Developer

Well-Known Member
Licensed User
Longtime User
Hi all!
I want to make an application that do some things when you go at specific place or you connect to a wifi.
I studied intent and service, a i think the best way to achieve this is to use a sticky service.
For wifi, i can use intent to start some things when i get a wifi change connection, but i don't understand how to do this. I tried using broadcast receiver, but some answer on forum tell to use phoneEvents, but i don't find nothing related to phone Events

For gps, i think the best way is use a sticky service that every x minutes, get the position and do some stuff.
How about android O and sticky service? Is there another idea?
Thanks all
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I studied intent and service, a i think the best way to achieve this is to use a sticky service.
Not really, especially not on newer versions of Android. Sticky services will be killed.

For wifi, i can use intent to start some things when i get a wifi change connection, but i don't understand how to do this.
See this tutorial: Intent Filters - Intercepting SMS messages in the background

Wifi changed: https://www.b4x.com/android/forum/t...tate_changed-in-background.70017/#post-444706
It will work on new devices as long as the targetSdkVersion <= 23.

You can use StartServiceAtExactWhileIdle to start the process every 30 minutes and check the last known location with FusedLocationProvider.
 
Upvote 0

Emme Developer

Well-Known Member
Licensed User
Longtime User
Not really, especially not on newer versions of Android. Sticky services will be killed.


See this tutorial: Intent Filters - Intercepting SMS messages in the background

Wifi changed: https://www.b4x.com/android/forum/t...tate_changed-in-background.70017/#post-444706
It will work on new devices as long as the targetSdkVersion <= 23.

You can use StartServiceAtExactWhileIdle to start the process every 30 minutes and check the last known location with FusedLocationProvider.
Hi, many thanks for the advice. Is there not a way to get in background position in a time less 30 minutes? I need a runtime event, that check position every 30 seconds
 
Upvote 0

Emme Developer

Well-Known Member
Licensed User
Longtime User
The OS will kill your app if you try to start it every 30 seconds. You can create a foreground service and keep running in the background.
A foreground service means that when an user kill the app, service will be killed?
 
Upvote 0
Top