Accessibility service disabled upon each debug run

天涯浪子 提交于 2019-12-02 23:16:07

This might go some way to explain and mitigate your problem (but not what causes your Force stop).

After Android 3.1 " the system sets FLAG_EXCLUDE_STOPPED_PACKAGES on all broadcast intents." So after 3.1 , all apps are stopped on boot. Why ?. For security reasons.

There are RULES to turn the flag off FLAG_EXCLUDE_STOPPED_PACKAGES.

(1) If the app get's a Force stop from settings OR unresponsive app button, the flag is set.

(2) Your app needs to be in Phone Storage, NOT external storage (e.g. sdcard) otherwise the flag set. The BOOT_COMPLETE is sent before external storage is mounted. So, if app is installed to external storage it won't receive BOOT_COMPLETE broadcast message.

(3) If the application has never been run, the flag is set (never is relative to current boot state ;O) NEVER means in THIS boot OR you invalidated the flag in the last boot state).

A quick way (scripted if you like) to re-enable your service after Force stop assuming BOOT_COMPLETED receiver (I'm guessing you have this, because your fine after reboot):

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"

adb shell am broadcast -a android.intent.action.BOOT_COMPLETED

See launchcontrols

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!