AccessibilityService gets unbinded when powered off and is not rebinded after reboot - android

I am facing an issue with AccessibilityService. When I power off my device AccessibilityService gets unbinded by invoking onUnbind. But when I start my device again, AccessibilityService is not rebinded and onRebind service is not called. I have checked using adb command adb shell dumpsys activity service .MyPackage.AccessibilityService and found my service is alive but is not receiving AccessibilityEvent as service is not rebounded. Everything starts working fine again after I stop and restart my AccessibilityService from settings. How can I fix this issue..? I though about using disableself at onUnbind that because it will force user to start the service from settings, but this call is available from API 24 . So, what should I do..?

I have searched a lot and tried almost everything could be done. Finally I came to a conclusion that this is a android bug, as this problem is not occurring on API 19 or later. For other developers who is suffering from this problem, I suggest you to use preference to store state of your service that it is rebinded or not. Now before you try to use your service check if your service is rebinded or not. If not, tell user that he/she will have to restart the service before using it.
I provided a more detailed answer here. check this out if you are still confused.

Related

How can I keep a BLE app alive all the time?

I'm trying to connect an App to a custom system with BLE that I added to my dog's door, which allows me to open/close it remotely as well as to know when is open "illegally" so it reproduce an alarm in my phone.
I've added the BLE class to the Main Activity and manage it from there, using fragments to see the data and sending commands.
But the problem I'm having is that, after some time, the App just close itself, breaking the BLE connection so I can't receive updates in "real time".
I don't know if is possible that the system don't kill the App, I've hear about services and that they keep the connection alive, but I'm not sure if they respect the other parts of the App or if the App get killed but the service don't. I've never worked with services before.
I've added the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission and also disabled the memory optimization as well but it still get killed.
When the app is killed and I press the App icon to open it, it looks like a fresh start and it should be keep alive all the time. Otherwise I will have "security issues" if something happens while I'm not connected.

Accessibility service is not working properly when device booted after power off

I have used AccessibilityService on my App to automatically Force stop Apps I desire to. Everything works fine unless I power off my phone. After turning my phone on AccessibilityService doesn't work properly. It doesn't call onAccessibilityEvent mathod until I turn off and restart My accessibility from settings. I have seen this answer, telling that it can be validated by using log in onDestroy. Can anyone explane how to do this, or how can I solve my problem..?

AccessibilityService restarting on boot

Once an Accessibility Service is connected by the user, is it restarted automatically on boot/reboot? This seems to be the case on an app I'm modifying. Just want to be sure after I couldn't find any info in the official docs.
This is expected behavior. If a user is relying on an assistive technology to use their device, they shouldn't have to start it up every time. Once it's on, it's on for good, unless it is intentionally shut off.

NotificationListenerService StopWorking After Sometime

I have implemented NotificationListenerService in my app. Its Working fine for First time. After sometimes its stop working and onNotificationPosted() never get called. But once i restart the device its start working. But After Sometimes again its Stopped.
I think GC may recycle the Notification service at some stage, and it can be reopen when reboot the device.
This service need to restart device to better working, yes its stoped after while time but if you restart you mobile device and use it without problem :)

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.

Categories

Resources