user2721305
user2721305

Reputation: 1

Running application on Android 13+ on Samsung Galaxy gests suspended even if having foreground services implemented

I have a less common business requirement - the need to implement an UDP listener contually receiving messages (sometime on seconds or minutes interval) and do some processing on data received. The requirement is that the application must run also also when not visible (other application is in foreground). To what I found, this can be achieved if the application has a foreground service, so the UDP lister has been implemented as such. Link (unfortunatelly only for Oreo, seems no changes since then) : https://developer.android.com/about/versions/oreo/background#services However, the application does not behave as expected, when I start other applications in the foreground, the UDP listener seem not to receive any more messages.

I wonder if my scenario is possible (I guess it should be, for example, Messages app works all the time, and probably many other, even if not using FCM or SMS services inside) and what other permissions requests / special steps I should consider. To be noted that the application is created in Xamarin C# (I know, just ran out of support this summer, however I guess this should not be an issue)

To be noted that the application fully works on Android emulator (tested on Google Pxie 5 API 34), it stay on backgroud and processes gracefully UDP messages received

I have done the following steps:

  1. Declared the following permissions in the manifest:

  2. Declared the service of type foreground : (.. in manifest ..) (.. C# class definition for service) [Service(ForegroundServiceType = Android.Content.PM.ForegroundService.TypeDataSync)] public class UdpReceiverService : Service

  3. During application launch, I check and request:

The application was tested on Samsung Galaxy devices - Ultra S23 and A55. The application was signed (local keystore), apk copied to device; when installed, I have requested not to scan (it is marked as unknown source by system). I am also thinking that maybe other component (Knox? other?) is maybe restricting background run for the application, even if it has a foreground thread and a notification.

Upvotes: 0

Views: 36

Answers (0)

Related Questions