I have a react native app that use paho mqtt (react native module) the problem is that when the screen is lock, this service die. Im not android developer but I read that the problem is that doze mode kill all and my paho service die after a few minutes.
I read this issue https://github.com/eclipse/paho.mqtt.android/issues/226 and test a solution given there but in android > 8 this solution not work anymore.
I think 2 possible solutions:
1. Run service again after unlock the screen (dunno how to do this for
android >8).
2. Restart the app after unlock the screen (Searching for how detect that the screen is unlock in react native).
If someone know how to handle this solutions or another one.
For Android native, you can use Service
A service is simply a component that can run in the background, even when the user is not interacting with your application, so you should create a service only if that is what you need.
I know you are using react-native, but hope the info would provide some hints.
Related
I'm using Ionic 2 to develop my Android project. I need to send a notification while have detected my iBeacon devices nearby even if my App has been exited.
The following plugins does not work for me:
Background mode: Works while App has been put in background. But what I need is to send notifications while the App has been killed.
Bgs: Doesn't work for me. The founder didn't try Ionic 2 project, so that he cannot figure out what may be the problem. But I do create a project here.
Just hope someone can tell me if it's possible to create an independent background service to retrive data. So that I can stop wasting time.
My goal is to make my app unkillable.
Application has admin permissions granted.
I have one activity and one service.
Applionation cannot be uninstalled while Admin permission is active (thats good).
Service is auto re-creating. That's also correct.
Unfortunately on Android 5 - Lollipop user can click on all apps button - then go to Task Manager and simply END my app without any problems. After that service is destroyed for good (activity too obviously...)
Is this a way to prevent that?
1) Xposed. At the cost of execution speed and dependency on the TaskManager that you will have to reverse-engineer a bit...
2) USER_PRESENT and friends. Your application can register a BroadcastReceiver and re-start on events. That is, it will be killable, but it will restart.
I think you are interested in something like a kiosk mode: displaying a single app and preventing to break out from it.
There are various tutorials out there. This one is quite good:
http://www.andreas-schrade.de/2015/02/16/android-tutorial-how-to-create-a-kiosk-mode-in-android/
Edit: if your main target are Android 5.0+ devices you can also make use of screen pinning. http://developer.android.com/about/versions/android-5.0.html#Enterprise
On the Android Market there is an app called Sleep Timer, and it is a type of alarm clock that brings runs the alarm even though you locked your phone while on facebook. I made a type of app that detects movement however it only works if the phone is left on that app... How can I make it work when the app wasn't left upfront, but is still running in the background?
You should take a look at Android Services, which provide the functionality you seek. Basically they enable you to create components that run in the background even when the user switch away from your application.
You can find a very good introduction to them here: http://developer.android.com/guide/components/services.html
I'm working on android application which have one service runs in background,
I need to make sure that the user will close the app/service only upon inserting password (like app lock on the market only for the service and the app).
Any ideas suggestion of how to implement such a feature?
On android 2.3 isn't possible the user will kill your app, but starting with Android 4.0 and Device Administrator it is: reasonable. Take a look at Kaspersky's parental control app.
I am a newbie on android apps development, I want to make a application which can lock any application when started. For eg if someone opens chrome or any other application it simply locks it.
Maybe you will not get any straight forward solution for that.you have to create a service that will run on the background.You can check periodically to find therunning process.Then you can find the package name for the process which you want to kill.Finally use killBackgroundProcess of the ActivityManager to kill the process.This method only kill background process.So if you want to stop browser that starts running simply send that in background(If you bring your activity in foreground it automatically will be back) and run the killBackgroundProcess(pkgName).
Android now allows users to add app widgets to the lock screen form API level 17, i dont know backward comparability supports or not