handle socket connection in background service for api 28
up vote
0
down vote
favorite
Before api 28 i can simply start a background service and continuously listen to a socket connection for any incoming data
however in recent changes in api 28 as shown here https://developer.android.com/about/versions/oreo/background#services
i can no longer start a background service in android 9 unless it covers only one of the following case
Under certain circumstances, a background app is placed on a temporary
whitelist for several minutes. While an app is on the whitelist, it
can launch services without limitation, and its background services
are permitted to run. An app is placed on the whitelist when it
handles a task that's visible to the user, such as:
Handling a high-priority Firebase Cloud Messaging (FCM) message.
Receiving a broadcast, such as an SMS/MMS message.
Executing a PendingIntent from a notification.
Starting a VpnService before the VPN app promotes itself to the
foreground.
The only option i found is to start service as a foreground .
I already found some alternative like using JobScheduler or WorkManger but i don't think they can cover my requirements
so my question is there any other way to listen for a socket connection that targets android 9 (api 28) other than using foreground service?
android background-service
add a comment |
up vote
0
down vote
favorite
Before api 28 i can simply start a background service and continuously listen to a socket connection for any incoming data
however in recent changes in api 28 as shown here https://developer.android.com/about/versions/oreo/background#services
i can no longer start a background service in android 9 unless it covers only one of the following case
Under certain circumstances, a background app is placed on a temporary
whitelist for several minutes. While an app is on the whitelist, it
can launch services without limitation, and its background services
are permitted to run. An app is placed on the whitelist when it
handles a task that's visible to the user, such as:
Handling a high-priority Firebase Cloud Messaging (FCM) message.
Receiving a broadcast, such as an SMS/MMS message.
Executing a PendingIntent from a notification.
Starting a VpnService before the VPN app promotes itself to the
foreground.
The only option i found is to start service as a foreground .
I already found some alternative like using JobScheduler or WorkManger but i don't think they can cover my requirements
so my question is there any other way to listen for a socket connection that targets android 9 (api 28) other than using foreground service?
android background-service
what do you mean what is the best practice? There is only one option and you already know what that is
– Tim Castelijns
Nov 7 at 11:48
u mean foreground service?
– has19
Nov 7 at 11:49
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Before api 28 i can simply start a background service and continuously listen to a socket connection for any incoming data
however in recent changes in api 28 as shown here https://developer.android.com/about/versions/oreo/background#services
i can no longer start a background service in android 9 unless it covers only one of the following case
Under certain circumstances, a background app is placed on a temporary
whitelist for several minutes. While an app is on the whitelist, it
can launch services without limitation, and its background services
are permitted to run. An app is placed on the whitelist when it
handles a task that's visible to the user, such as:
Handling a high-priority Firebase Cloud Messaging (FCM) message.
Receiving a broadcast, such as an SMS/MMS message.
Executing a PendingIntent from a notification.
Starting a VpnService before the VPN app promotes itself to the
foreground.
The only option i found is to start service as a foreground .
I already found some alternative like using JobScheduler or WorkManger but i don't think they can cover my requirements
so my question is there any other way to listen for a socket connection that targets android 9 (api 28) other than using foreground service?
android background-service
Before api 28 i can simply start a background service and continuously listen to a socket connection for any incoming data
however in recent changes in api 28 as shown here https://developer.android.com/about/versions/oreo/background#services
i can no longer start a background service in android 9 unless it covers only one of the following case
Under certain circumstances, a background app is placed on a temporary
whitelist for several minutes. While an app is on the whitelist, it
can launch services without limitation, and its background services
are permitted to run. An app is placed on the whitelist when it
handles a task that's visible to the user, such as:
Handling a high-priority Firebase Cloud Messaging (FCM) message.
Receiving a broadcast, such as an SMS/MMS message.
Executing a PendingIntent from a notification.
Starting a VpnService before the VPN app promotes itself to the
foreground.
The only option i found is to start service as a foreground .
I already found some alternative like using JobScheduler or WorkManger but i don't think they can cover my requirements
so my question is there any other way to listen for a socket connection that targets android 9 (api 28) other than using foreground service?
android background-service
android background-service
edited Nov 7 at 12:04
asked Nov 7 at 11:46
has19
340416
340416
what do you mean what is the best practice? There is only one option and you already know what that is
– Tim Castelijns
Nov 7 at 11:48
u mean foreground service?
– has19
Nov 7 at 11:49
add a comment |
what do you mean what is the best practice? There is only one option and you already know what that is
– Tim Castelijns
Nov 7 at 11:48
u mean foreground service?
– has19
Nov 7 at 11:49
what do you mean what is the best practice? There is only one option and you already know what that is
– Tim Castelijns
Nov 7 at 11:48
what do you mean what is the best practice? There is only one option and you already know what that is
– Tim Castelijns
Nov 7 at 11:48
u mean foreground service?
– has19
Nov 7 at 11:49
u mean foreground service?
– has19
Nov 7 at 11:49
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Nice Question. I have also survived with service. Foreground service also not a better solution for Android 9. Cause due to system resource circumstances foreground service also can be killed.
Better you can use WorkManager
. It will give you a nice flavor.
Give it to a try.
i am not sure but i don't think i can use workmanager for a long running task like background service
– has19
Nov 7 at 12:47
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Nice Question. I have also survived with service. Foreground service also not a better solution for Android 9. Cause due to system resource circumstances foreground service also can be killed.
Better you can use WorkManager
. It will give you a nice flavor.
Give it to a try.
i am not sure but i don't think i can use workmanager for a long running task like background service
– has19
Nov 7 at 12:47
add a comment |
up vote
0
down vote
Nice Question. I have also survived with service. Foreground service also not a better solution for Android 9. Cause due to system resource circumstances foreground service also can be killed.
Better you can use WorkManager
. It will give you a nice flavor.
Give it to a try.
i am not sure but i don't think i can use workmanager for a long running task like background service
– has19
Nov 7 at 12:47
add a comment |
up vote
0
down vote
up vote
0
down vote
Nice Question. I have also survived with service. Foreground service also not a better solution for Android 9. Cause due to system resource circumstances foreground service also can be killed.
Better you can use WorkManager
. It will give you a nice flavor.
Give it to a try.
Nice Question. I have also survived with service. Foreground service also not a better solution for Android 9. Cause due to system resource circumstances foreground service also can be killed.
Better you can use WorkManager
. It will give you a nice flavor.
Give it to a try.
answered Nov 7 at 12:25
Al-Amin
1428
1428
i am not sure but i don't think i can use workmanager for a long running task like background service
– has19
Nov 7 at 12:47
add a comment |
i am not sure but i don't think i can use workmanager for a long running task like background service
– has19
Nov 7 at 12:47
i am not sure but i don't think i can use workmanager for a long running task like background service
– has19
Nov 7 at 12:47
i am not sure but i don't think i can use workmanager for a long running task like background service
– has19
Nov 7 at 12:47
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53188840%2fhandle-socket-connection-in-background-service-for-api-28%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
what do you mean what is the best practice? There is only one option and you already know what that is
– Tim Castelijns
Nov 7 at 11:48
u mean foreground service?
– has19
Nov 7 at 11:49