Android Question Activity Recognition Detection Service

jtare

Active Member
Licensed User
Longtime User
I'm testing the Physical Activity Recognition Detection Library, and for what I've been reading in the forums, this solution is not based on a static intent filter, meaning that once the service is killed it will no longer receive updates from the api. The solution to this will be creating a foreground service with a partial lock. This means that there is no way to use activity recognition in a service without having a notification in the status bar? Most of the time, the service is just waiting for the api update, is not doing work that justify the notification.

It is possible to use it as a static intent filter, like the "Intercepting SMS" example, or firebasemessaging, which don't required a notification in the status bar, the service is created if needed (when the api updates).

Thanks.
 

jtare

Active Member
Licensed User
Longtime User
"Once you connect your app to these services you will receive notifications even when your app is in the background (similar to static intent filters).'

It behaves the same as static intent filters.
I must be doing something wrong then, will check the example code again. For what I seen working with the library is that once the service is killed it won't be created and started again.

Maybe is because I move the activity recognition object to the same service is calling?
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
From what I understand, there are two types of intents:

1) Static intents that you define in your manifest and will start your service even if the service it not running so that it can handle the intent. And I do not believe that the service that handles static intent needs to display an icon in the status bar. However, only certain intents can be defined as static - not all intents can be setup as static.

2) Dynamic intents are intents that you define at runtime, but your service must be running to receive and handle dynamic intents - they will NOT auto-start your service. And to make sure your service keeps running (to handle dynamic intents), it may be required to show a notification icon when your service is running.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I must be doing something wrong then, will check the example code again. For what I seen working with the library is that once the service is killed it won't be created and started again.

Maybe is because I move the activity recognition object to the same service is calling?
Make sure to test it in release mode and don't explicitly kill the app. It can change the behavior.
 
Upvote 0

jtare

Active Member
Licensed User
Longtime User
From what I understand, there are two types of intents:

1) Static intents that you define in your manifest and will start your service even if the service it not running so that it can handle the intent. And I do not believe that the service that handles static intent needs to display an icon in the status bar. However, only certain intents can be defined as static - not all intents can be setup as static.

2) Dynamic intents are intents that you define at runtime, but your service must be running to receive and handle dynamic intents - they will NOT auto-start your service. And to make sure your service keeps running (to handle dynamic intents), it may be required to show a notification icon when your service is running.
I believe is the second case, a dynamic one, I don't see the intent filter in the manifest.

Make sure to test it in release mode and don't explicitly kill the app. It can change the behavior.
I'm testing like this, just exit the app with the home button. How can I make it more reliable in the likely scenario of the app being killed by the os or user?
 
Upvote 0

jtare

Active Member
Licensed User
Longtime User
If implemented and configured correctly, the app will start automatically after it is killed by the OS. It might take some time.
I notice that the example in the library thread is targeting sdk version 14, and it works fine even if the app is killed after several hours it is still receiving notifications. But when I change the target sdk version to 28, the service gets killed almost immediately after the app is exited and does not receive any notifications.
 
Upvote 0
Top