Auto start when speed (GPS) is higher than value

brelto85

Active Member
Licensed User
Longtime User
Hi,

Exist a method (register an intent or another ecc...) to start app when GPS fired a location change?

I need to start my app automatically when the user is in the car and the speed is higher than a value
 

bgsoft

Well-Known Member
Licensed User
Longtime User
Hi:

1)
Create a service

2)
Call then service: StartService(ServiceName)
Ends the application: Activity.Finish

3)
In the service can check the change in location every x time

B4X:
Sub Service_Start (StartingIntent As Intent)

'GPS check code
'.....
'.....


'Calling new every n minutes
StartServiceAt ("", DateTime.Now + n * DateTime.TicksPerMinute, True)

'Calling new every n seconds
StartServiceAt ("", DateTime.Now + n * DateTime.TicksPerSecond, True)

'Note, only one line, or in minutes or seconds


end sub


3)
When you want to stop the service can do so:

B4X:
Sub Button1_Click

If IsPaused (NameService) = False Then ' checks if the service is running
   CancelScheduledService (NameService) 'service removes the Schedule
   StopService (NameService)  ' Stop service
End If

end sub


Jesús
 
Upvote 0

brelto85

Active Member
Licensed User
Longtime User
is the only way?

i don't want start service manually. i want start the service with a GPS intent or SPEED intente (if exist)
 
Upvote 0

bgsoft

Well-Known Member
Licensed User
Longtime User
The service is for the program to run in the background.
You put the program in place and activate the service and stops the application, but the service is ongoing.
From the service each x time (I put you before) you verify if the GPS changed. And when change, you call your application
 
Upvote 0
Top