That exception gets thrown when you are trying to send an event to a window that is not part of your app. You need to figure out what is causing your app to not be the target.
clickLongOnScreen(x,y) and clickLongOnView(v) returns "Injecting to another application requires INJECT_EVENTS permission"
Question
using com.bitbar.recorder.extensions.ExtSolo to test long click on screen and on view returns java.lang.SecurityException.
View v = findViewById("com.view.id");
int location[] = new int[2];
v.getLocationOnScreen(location);
clickLongOnScreen(location[0], location[1]);
and
clickLongOnView(v);
full error message:
java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission
at android.os.Parcel.readException(Parcel.java:1327)
at android.os.Parcel.readException(Parcel.java:1281)
at android.view.IWindowManager$Stub$Proxy.injectPointerEvent(IWindowManager.java:1203)
at android.app.Instrumentation.sendPointerSync(Instrumentation.java:902)
at com.jayway.android.robotium.solo.Clicker.clickLongOnScreen(Clicker.java:117)
at com.jayway.android.robotium.solo.Clicker.clickOnScreen(Clicker.java:154)
at com.jayway.android.robotium.solo.Solo.clickLongOnView(Solo.java:933)
at com.bitbar.recorder.extensions.ExtSolo.a(ExtSolo.java:3525)
at com.bitbar.recorder.extensions.a.a(Clicker.java:63)
at com.bitbar.recorder.extensions.a.a(Clicker.java:84)
at com.bitbar.recorder.extensions.ExtSolo.clickLongOnView(ExtSolo.java:1394)
at com.ui.android.test.UI.longClickAndDrag(UI.java:174)
at com.ui.android.test.Test_1_17_006_LONGPRESS(Test.java:1153)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:545)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1551)
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow