Android 8.0 Oreo RunningServiceInfo returns 0 services

January 13, 2018, at 09:18 AM

my Oneplus 5 just updated to Oreo and something has broken. I have a simple widget which starts and stops some service.

But now, when I request List of services I got nothing

ActivityManager manager = (ActivityManager) context.getSystemService( Context.ACTIVITY_SERVICE );
List<RunningServiceInfo> service = manager.getRunningServices( Integer.MAX_VALUE );
Log.v( "ServCount", "size service: " + service.size() );

returns 0

Please help :'(

Answer 1

Quoting the documentation:

This method was deprecated in API level 26. As of O, this method is no longer available to third party applications. For backwards compatibility, it will still return the caller's own services.

So, if you do not have a service running, getRunningServices() will return an empty list on Android 8.0+.

In App purchase in Libgdx [on hold]

In App purchase in Libgdx [on hold]

I am planing to integrate in-app purchase in my Libgdx game but unfortunately Libgdx does not have a good (in-app purchasing) implementation tutorial on their Github wiki and the only source is to look into https://githubcom/libgdx/gdx-pay so I copy-pasted...

Using fragments with NativeActivity

Using fragments with NativeActivity

I have a fully working C++/OpenGL engine that I ported over to Android using their supplied NativeActivityBut I'm now tasked with integrating it to an older project which was 100% Java, with plenty of Fragments

Android Programming - Always Restarts same Intent

Android Programming - Always Restarts same Intent

I am using Android Studio for a simple communication app and this definitly might be a stupid question but I couldn't find the answer to it yet