Broadcast service being killed - android

After locking an app, though it is available in recent app page, when we goto app info page, the 'Force close' option is not enabled suggesting the app is already closed. How is this possible?
Another indication is, the app is using a broadcasting service and it is not being triggered implying app is killed.

Related

Android and background processes

I wrote an bluetooth app with my bt-connection established in a service, so the connection is still alive when I minimize my app.
But when watching my task manager, my app is still there.
And when calling onDestroy in my app, I have to stop my Service.
But other apps like telegram or skype (whatsapp too I think) aren't in my task-manager visible but by having an incoming message they notify me nevertheless.
How is this even possible? How can I write my bluetooth connection like this, that I can really close my app and anyway the incoming messages will be handled?
The other apps might be having some light weight service running in other process which gets the data for the main app.Go to settings->application manager->running processes..you will see all the service..
Other mechanism which apps use is port-directed sms. In such a scenario you don't need any service running.However port directed sms doesnt work on all the phone and for all the apps.
When you put remove your application from the foreground, Android keeps the activity on the stack again in case you will go back to it (unless you explicitly destroy the activity). So this maybe one reason why you still see it in the Task Manager.
You cannot kill entirely the app and it will still post messages. Your service will be running in the background and it will be visible in the app Manager->Running Services.
However if you destroy your activities the app it will not be visible in the app list of the Task Manager.

How to keep listening the S Pen detachment after the app gets closed from the Recent Apps list?

The goal is simple: to start an app when S Pen is detached. It is clear that it should be a service running even when the app is not running. This answer provides a good example of how to create a service to listen S Pen detachment by registering a receiver with BOOT_COMPLETED action. It does not matter whether you start your service from the app activity, or by registering a receiver - it works fine if you just "close" the app using Back button. But if you go to the list of recent apps and clear the app out of the list - the service stops and it does not work until you restart the device again. Does anyone have an idea how to keep listening the S Pen detachment even after the app was cleared out of the Recent Apps list?
Register a Broadcast Receiver for com.samsung.pen.INSERT as described in this answer: Bring your app to the front when S Pen detached in android note?

GCM to get push notifications if I Force stop the app

I have used GCM to get push notifications, now if I Force stop the app from the settings on the Android device, will it be able to get push notifications without restart application...
No. If the user force-stops your app, they are indicating that they do not want your app to run again, for any reason, until they manually launch it again. Your objective is to give the user no reason to force-stop your app. Note that I do mean "force-stop" (i.e., press the "Force Stop" button from Settings) -- ordinary task managers, or swiping from the Recent Tasks list in Android 4.x, does not have this effect.

App resumes and comes to the foreground unexpectedly

When my app is running in the background under some certain circumstances it comes to the foreground unintentionally. Based on user accounts it has happened when receiving phone calls or when data connectivity changes.
I use google analytics, admob sdk, and couchbase mobile. Any clue as to what would cause an app to come to the foreground without the user doing anything would be helpful
You most likely have a service or a receiver running that triggers the activity to start if a certain event occurs. Also check the manifest to see if you have some weird configurations set there

GCM push notification works after app Force Stop?

I have used GCM to get push notifications, now if I Force stop the app from the settings on the Android device, will it be able to get push notifications?
I have read many posts that say in this case an app cannot receive notifications.
Is there any possibility to get notifications?
Once you force-stop your app from Settings, your code will not run until something manually runs one of your components (ie the user manually launches an activity).
Therefore after force-stopping your app from Settings, you will not receive GCM messages.
If you want to get notifications you have to manually restart your app.
This is by design since Android 3.1.
Apps that are in the stopped state do not receive broadcast Intents.
Stopped state is:
when the app is initially installed (before the user runs something in
the app) or
after a Force Stop.
You can find more about this here: http://developer.android.com/about/versions/android-3.1.html#launchcontrols

Categories

Resources