Injecting to another application requires INJECT_EVENTS permission

本文介绍了解决使用ADB命令时遇到的java.lang.SecurityException错误的方法。该异常通常发生在尝试向其他应用注入事件时,解决方案是在开发者选项中启用USB模拟点击。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


PS C:\Users\Dell\Desktop> adb shell input keyevent 3
java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission
        at android.os.Parcel.createExceptionOrNull(Parcel.java:2376)
        at android.os.Parcel.createException(Parcel.java:2360)
        at android.os.Parcel.readException(Parcel.java:2343)
        at android.os.Parcel.readException(Parcel.java:2285)
        at android.hardware.input.IInputManager$Stub$Proxy.injectInputEvent(IInputManager.java:1012)
        at android.hardware.input.InputManager.injectInputEvent(InputManager.java:907)
        at com.android.commands.input.Input.injectKeyEvent(Input.java:355)
        at com.android.commands.input.Input.access$100(Input.java:41)
        at com.android.commands.input.Input$InputKeyEvent.sendKeyEvent(Input.java:203)
        at com.android.commands.input.Input$InputKeyEvent.run(Input.java:190)
        at com.android.commands.input.Input.onRun(Input.java:107)
        at com.android.internal.os.BaseCommand.run(BaseCommand.java:60)
        at com.android.commands.input.Input.main(Input.java:71)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:463)
Caused by: android.os.RemoteException: Remote stack trace:
        at com.android.server.input.InputManagerService.injectInputEventInternal(InputManagerService.java:812)
        at com.android.server.input.InputManagerService.injectInputEvent(InputManagerService.java:786)
        at android.hardware.input.IInputManager$Stub.onTransact(IInputManager.java:459)
        at android.os.Binder.execTransactInternal(Binder.java:1157)
        at android.os.Binder.execTransact(Binder.java:1126)

 

 

只要去开发者模式, 把usb模拟点击打开即可, 

如果找不到. 可能是名字叫usb调试(安全模式)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值