经常有人问我怎么用代开辅助功能
一 先放结论
AndroidManiferst.xm需要添加权限
<uses-permission
android:name="android.permission.WRITE_SETTINGS" />
<uses-permission
android:name="android.permission.WRITE_SECURE_SETTINGS" />
targetSdkVersion 版本必须低于23
targetSdkVersion 21
打开控制台 需要使用adb命令,非常重要
adb shell pm grant 包名 android.permission.WRITE_SECURE_SETTINGS
然后代码调用
Settings.Secure.putString(getContentResolver(),
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES,
"org.telegram.accessibilityapplication/org.telegram.accessibilityapplication.AccessibilityTestService");
Settings.Secure.putInt(getContentResolver(),
Settings.Secure.ACCESSIBILITY_ENABLED, 1);