Reputation: 31
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 :'(
Upvotes: 3
Views: 1083
Reputation: 1006674
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+.
Upvotes: 4