Hey Community,
I have a GPS Sensor and I want that it becomes closed when you click on its notification. I've done that with a separate Activity called "StopGps", that only kills the service when it gets started and kills itself immediately after. That worked not very well but it worked often.
Now I changed it to the Main Module and I am using that Code before all other lines in Activity_Create and Activity_Resume:
So in fact there are two killing code lines before all other Activity_Create Code and in _Resume another time... but somehow that does not work. When i click on the notification while the app is paused it opens the app after stopping the service nevertheless...
Sadly i am not allowed to publish the project...
But could you please help me anyway? I am also interested if there is a more easy way to kill the Service when clicking on its notification
Thank you so much
I have a GPS Sensor and I want that it becomes closed when you click on its notification. I've done that with a separate Activity called "StopGps", that only kills the service when it gets started and kills itself immediately after. That worked not very well but it worked often.
Now I changed it to the Main Module and I am using that Code before all other lines in Activity_Create and Activity_Resume:
B4X:
Dim StartingIntent As Intent = Activity.GetStartingIntent
If StartingIntent.HasExtra("Notification_Tag") Then
If StartingIntent.GetExtra("Notification_Tag") = "StopGPS" Then
StopService(GPS)
GPSStopped ' A sub thats testing if the user had open the app when he clicked on notification and if its yes it saves the last values - It's not important to know for my StopService problem: It only writes some personal App settings into a file
ExitApplication
Activity.Finish
End If
End If
So in fact there are two killing code lines before all other Activity_Create Code and in _Resume another time... but somehow that does not work. When i click on the notification while the app is paused it opens the app after stopping the service nevertheless...
Sadly i am not allowed to publish the project...
But could you please help me anyway? I am also interested if there is a more easy way to kill the Service when clicking on its notification
Thank you so much
Last edited: