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

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).

Related

How to lock (other) apps with password?

I've seen some "app locking" solutions in the Google Play store and I was wondering how those apps work. I'd like to build something similar.
I realize that this might require some special permission or maybe request the app to be added as device administrator.
Is there some broadcast that is triggered just before an app is launched that I can intercept and do some action (e.g. launch an activity that will request the user to fill a password)? I've read some lengthy discussions how this is not a good idea and the only idea is to have a background service that will continuously poll the running processes and check for changes, but I think retrieving this list every second and checking it for chances is not good for the battery and I think other app locking apps out there must be using a different approch.
If possible, without the need for a rooted phone.

Running a Service without opening the application

After 3.1 , Android introduced a security feature, where the application's code can't be run unless the user opens the application. Check the link for more info http://commonsware.com/blog/2011/07/13/boot-completed-regression-confirmed.html
I would like to know if anyone has found any hack or work around for this problem, where i can listen to a system broadcasts like boot, connectivity changed and run a service without opening the installed application.
This is not what the posts said. You can still register broadcast listeners, or alarms. You just need the user to actually start your application once. And, if the user forcefully stops your application, they'll need to start it manually again.
Why would you want a way around this behavior? It seems to make a lot of sense.

Other apps gets the message before my application

In my application, after receiving a specific message i do some task. It works well but when some other sms applications like HookUp(in micromax) and go sms pro is installed in device, these application also gets the message. I have set highest priority to my application. I want to stop bypassing the sms to these application. Please help
Thanks in advance
I want to stop them But dont know how?
Ask the user to uninstall those apps.
My guess is that the tiebreaker for BroadcastReceivers registered at the same priority is installation order. That seems to be the behavior, based on described behavior in these StackOverflow questions. Hence, if these other apps were installed before yours, they will get the broadcasts first, and there is nothing that you can do about it.
If the user values your application enough, they will uninstall those other apps (which definitely gives you priority), perhaps reinstalling them later (which may give you priority).

How do you run code after an Android application has been installed?

Does anyone know of a good way to have code run after their Android application has been installed?
Something like ACTION_PACKAGE_ADDED that would get delivered to the application that was just installed.
–
This is for a zero configuration scheme where the configuration for the device comes from a webservice.
These settings are used in BroadcastReceivers.
One approach is to fetch the settings the first time. Since this would be done BroadcastReceiver, and since it might take a moment to fetch the result, I'm reluctant to use this approach.
The intent ACTION_PACKAGE_ADDED will not be received by the just-installed application. However, there may be some broadcast messages to trigger on in order to start your application automatically. I think, the best way is to use the BOOT_COMPLETED broadcast message, so the settings are loaded the first time device powers on.
I don't now anything about your device, but whenever you are providing Android on these devices, you could pack this app (and your settings) within a firmware update. Or you'll just reboot the device after installing this package..

How to Lock(Block) an android application from starting / How to stop an android application (service) from starting at boot

I would like to know if there is a way to lock (prevent) an application from starting.
And i also would like to know if there is a way to prevent a service(application) from starting at boot of the device
...i would like to know because i would like to create an anti-malware app.
I know this question is old, but for others stumbling over it:
Autostarts is an application that can disable apps from starting at boot time. It's the best I've found to do that (it isn't resident and doesn't kill processes like a task manager, it actually parses apk packages and reads registered actions and blocks the actions you tell it to). BUT it needs root and hasn't been updated for a while (december 2011). It works on Android 2.3 on which I tested it. Because it was discontinued, I don't know if it works on newer OS versions.
It's commercial now, but that's not the point, you need a peek at the source code.
If you search a bit, you'll be able to find the source code for an older version and see how it implements the blocking system.
I would be very interested in an application that could block certain services. NOT kill, but prevent them from starting in the first place. And the list is quite big: Facebook (OrcaService, MqttPushService, MediaUploadService, BackgroundDetectionService), Twitter, Maps (NetworkInitiatedService), Yahoo Mail Sync, etc. I don't use the features that the services provide, I even disabled some of them in the app interface where possible, but they still pop up and remain resident after exiting the application.
I would like to know if there is a way to lock (prevent) an application from starting.
Not in any supported fashion. Anything that does this is malware, and the techniques for doing it are security holes.
And i also would like to know if there is a way to prevent a service(application) from
starting at boot of the device
The user can boot their phone in safe mode (I forget the exact process, but it's something like holding down the HOME key while turning the phone on).

Categories

Resources