Android 5.0 force stop behavior - android

Just update to Android 5.0 by OTA. The biggest find is that if a user Force Stop my app(in System Setting), my app stops right now. And my app cannot receive any broadcast anymore, even if my receiver is registered in AndroidManifest.xml. More surprisingly, when the user reboot the device, my app even cannot receive android.permission.RECEIVE_BOOT_COMPLETED broadcast.
Does anyone pay attention to this?

Yes, I just noticed that on my Nexus 5, and I'm really loving it!
When the user "Force Stop" an app in Settings->Apps, it will be TOTALLY stopped and is black listed from receiving any broadcasts UNTIL the user open the app from the launcher.
I see it as a way like the "Disable" of system apps, you completely disable this app until you open it again.
I see this really very useful as I have lots of apps that are using unnecessary services in the background like Facebook for instance.

Related

Not getting push notification when swipe from recent

I'm not getting notification when user swipe the app from recent. I've notice that behavior occurs in some specific device for instance I've tested it on nexus devices and HTC devices it's working fine but when user swipe the app from the recent in huawei and some samsung devices it doesn't show notification. I mean i don't get onMessageReceived() callback
After some research I found out that in these devices when user swipe it from recent it force stop the app (the process is completely killed) and I don't get any notification. In huawei they have protected and unprotected apps and if I add the app in protected list from the setting, I start getting notification because i this case it doesn't force stop the app. and I believe in samsung they have the same thing with blacklist and whitelist apps.
I've also tried some solutions like restart the service onTaskRemoved() callbacks or make your app START_STICKY. I've also tried WakefulBroadcastReceiver but nothing is working for me.
So my question is how can i get notification even if it gets forced stop, like it's happening when swiping app from recent.
An old question, but I think it’s important to know that HUAWEI has a feature called “power-intensive app monitor “. It kills every app that runs in the background for a long time unless user gives special permissions to it.
The path to do this:
Settings -> Security & privacy -> Location services -> recent location requests: YOUR APP NAME -> Battery -> uncheck Power-intensive prompt, App launch: Manage manually: check all three positions: Auto-launch, secondary launch, run in background.
I don’t know if there's a way to do this programmatically. I think the best way is to create a sort of help activity and explain the user what to do if application won’t work.

Broadcast Receiver for permission change in settings

In Android M, if user manually changes the permission in settings for my app it always restarts my app and activity. This leads to abnormal behaviour in most of the screens.
Is there any broadcast receiver to know user has revoked/granted permission from settings? Or is there any other way to handle this restart behaviour?
You appear to have a non-functional app - there are many reasons why Android might stop and restart the app, so if your app misbehaves when that happens, you need to fix your app.
The restart when permissions change is new in Marshmallow, and there is no way to opt out of that behaviour and be notified in a different way.

No service without activity? (Android)

I'm trying to write an Android service, which starts on boot and works in the background periodically. I have defined the BroadcastReceiver of mine, added the right permissions and all the necessary stuff in manifest.
When I install the APK on my phone and reboot, nothing happens, the program is there in the installed apps section, but not running.
I've seen a user comment stating that "standalone" services are disabled (for security reasons?) since Android 3.1 but I couldn't verify this information anywhere.
Anyone could give me a clear view about this? Without that, I don't know how to proceed: debug or change plans.
Thank you in advance!
Just after the first the first installation of a package, the application is in a "stopped state" preventing it to execute any code for security reasons.
The app loses this particular "stopped state" as soon as the user launch the app explicitly for the first time.

(Android) Keep service running, even when app is stopped by force

I have created an app. Works great, but I want some same functionality as gmail uses:
When I receive a new email, I get a notification. I inspected my phone and saw no services or applications running that look like the gmail-app.
I have investigated the AlarmManager and services, but as soon as I stop the app both don't work anymore.
Could someone give me a hint how to accomplish this?
Thanks in advance
I inspected my phone and saw no services or applications running that look like the gmail-app.
Partly, that is because Gmail gets such notifications via broadcast Intents from the OS, via the subsystem we see as C2DM (which is why you do not see a process). Partly, that is because Gmail is part of the firmware and may get some extra benefits as a result, in terms of resisting the normal behaviors that befall an app that is force-stopped.
Could someone give me a hint how to accomplish this?
You can't. Particularly on Android 3.1+, if your app is force-stopped, it will not run again until the user manually runs one of your activities (e.g., from the launcher).

Disabling "Force Stop" Button in Android

Okay, I'm pretty sure that this is not possible but a client had asked me to do so in one of our Android application we developed for her.
What she had wanted is that if our application is running, and user navigate to:
Settings > Manage Application > [Our Application]
, the button for "Force Stop" is disabled.
Is this possible? If it is possible, could someone point me out which way I should walk, or if it is not possible, how, using a valid argument based on facts, should I break the news to her.
Update:
She just sent me a screenshot that, in her opinion, validates her request that there's an Android application that disables "Force Stop" button. How am I supposed to explain this to her?
How to disable the "Force Stop" button
Short answer: Use the Device Administration API.
How to explain this to my client?
Show this to your client. It is a nice slideshow providing an easy-to-understand overview of the Device Administration API and its uses.
How do I demonstrate that it works?
Yes, back to your job. Use the API link provided above and the Api Demos included in Google's sample
collection to figure out how to integrate this into your app.
Build the demo and run it on your device.
Choose API Demos->App->Device Admin->General->Enable admin.
Choose Activate once the Device Administration API prompts you with its enabling screen.
Exit the app and attempt to manage the app via your device's settings menu (specifics for this step varies by device).
When viewing the Api Demo's "app info" screen, you should see both Force Stop and Uninstall are disabled.
How do I do this in my own app?
Review DeviceAdminSample.java in the Api Demos app for inspiration. You will need the following:
The following code is what brings up the activation screen:
// Launch the activity to have the user enable our admin.
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, mDeviceAdminSample);
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,
mActivity.getString(R.string.add_admin_extra_app_text));
startActivityForResult(intent, REQUEST_CODE_ENABLE_ADMIN);
However, there are a few other pieces you will need to get this to work:
A broadcast receiver that derives from DeviceAdminReceiver.
Entries in your manifest file that refer to the above broadcast receiver.
Permissions in your manifest for using the Device Administrator API.
An xml file stating what policies your app can access.
All of this can be found in the above links. Good luck with your client!
This is not remotely possible, for great reason.
You should tell her that making this possible would be a huge security disaster. Imagine what would happen if you could create apps which just ate at your processor time by holding a wake lock, and you couldn't kill them. This would be horrible.
In general, if you're wondering if you can modify the "extra-app" behavior of the device, the answer is usually *no*. You should take the viewpoint that nothing on the device is yours to control besides your app and (to a limited extent) the resources to which you're granted access.
No other app has this kind of control, so it's not reasonable to expect that your client's would either. However, the fact that she's asking for this control usually implies something else: that they are worried the user will stop the app and then something bad will happen (the locations will stop being synced, data will stop being sent out to the net, etc...). This would imply that you should look into improving the resilience of the app to different situations. Remember, your app can even be killed off at any time by Android (for example, in the case of low memory).
I think the device screen shot has confused us. Even I can show my application that is installed on the device and the "Force Stop" button is disabled. Where as I have not done any thing specific to that.
The reason of the "Force Stop" button being disabled is, that particular application is NOT running currently. Hence there is not meaning in having the button enabled.
#Rhama you can ask your client to start the application once, press the home button of the device, and goto the settings and see. Surely the "Force Stop" button will be enabled this time.
Regards,
Rajan
From ICS, disabling Force stop is possible. If your app has an active device admin then the framework will not allow user to kill the process
Hey I think it is quite possible to disable the "Force Stop" button...check Kaspersky
Parental Control from the market it is doing the same.
Its service is running in the background then also the force stop button is disabled.
The application service is running in background
you can disable the forcestop when the app has admin rights. but soon as those admin rights are revoked then it is back to normal. however in android 4, an application called applock (domobile) was able to prevent that by asking a password when you tried to change admin rights. It could only be done by installing an extra program that applock asked you to. And I guess this might even be seen as a security flaw, infact it no longer works in Android 5.

Categories

Resources