Can you use a LoaderManager from a Service?

Does anyone know why LoaderManager was excluded from Service? As stated in the other answer, LoaderManager was explicitly designed to manage Loaders through the lifecycles of Acivities and Fragments. Since Services do not have these configuration changes to deal with, using a LoaderManager isn’t necessary. If not is there a way around this? Yes, the … Read more

Android Library Manifest vs. App Manifest

Using a Library Project means that my overall project will have two manifests — one for the library and the other for the “main” app project — and I’m not clear what goes in which or if there is some redundancy. The library project manifest is not presently used. Gradle for Android, and therefore Android … Read more

Using Job Scheduler in Android API

from now on (after I/O 2015), you can also use new GcmNetworkManager. How to use it and how it works is described here – https://developers.google.com/cloud-messaging/network-manager It does a lot cool stuff like it persists your tasks trough reboots. On Lolipop it uses JobScheduler, on pre-Lolipop it uses it’s own implementation. EDIT: An example code on … Read more

Get rid of “Exported service does not require permission” warning

The warning is telling you that you have exported (ie: made publicly available) a service without securing it with a permission. This makes your service available to any other applications without restrictions. See Exported service does not require permission: what does it mean? If your service doesn’t need to be available to other applications, you … Read more

Fatal Android 12: Exception: startForegroundService() not allowed due to mAllowStartForeground false

Apps that target Android 12 (API level 31) or higher can’t start foreground services while running in the background, except for a few special cases. If an app tries to start a foreground service while the app is running in the background, and the foreground service doesn’t satisfy one of the exceptional cases, the system … Read more

how to prevent service to run again if already running android

A service will only run once, so you can call startService(Intent) multiple times. You will receive an onStartCommand() in the service. So keep that in mind. Source: Note that multiple calls to Context.startService() do not nest (though they do result in multiple corresponding calls to onStartCommand()), so no matter how many times it is started … Read more

Android O Replacement for getRunningServices

It is intentional that there is no replacement for this function. It is not too clear from the documentation, but from the docs: Note: this method is only intended for debugging or implementing service management type user interfaces. Basically, using the method to check other apps services was an unintended side-effect, so Google decided to … Read more

Bad notification posted – Couldn’t expand RemoteViews for: StatusBarNotification

For me, the problem was that I was setting a specific height for the root layout, in the custom notification view xml file. As soon as I changed: android:layout_height=”@dimen/notification_expanded” to android:layout_height=”match_parent” in the root layout of notification view, the problem was solved. Also take a look at this example to see a simple example of … Read more