Reputation: 440
what is proper way to Use INJECT_EVENTS. I try using this Instrumentation.sendPointerSync(motionEvent) and try to injcet event to other application to listener touch but INJECT_EVENTS Its still throwing the permission exception.
guide me how to do it properly. thank you
Upvotes: 1
Views: 175
Reputation:
it is android.permission.INJECT_EVENTS.
Allows an application to inject user events (keys, touch, trackball) into the event stream and deliver them to ANY window.
Without this permission, you can only deliver events to windows in your own process.
Not for use by third-party applications.
The security exception that you get means that the test cases are trying to interact with an application that they are not allowed to interact with (e.g. another application or the platform). This tells me that Note pad does not start when your test cases start to execute.
One example when this can happen is when the emulators lock screen is active. Then the test cases try to interact with the lock screen instead and therefore a security exception is thrown.
Can you please make sure that Note pad does indeed start when you select the example test project and click run application as Android JUnit Test.
If it does not start, try to run Note pad separately by right clicking it and select run as Android Application.
If that is successfull then try to run the test cases again.
Upvotes: 1