How can I force touch events on none routed Android devices

前端 未结 2 947
-上瘾入骨i
-上瘾入骨i 2021-01-29 02:25

I would like to write an application which can programatically generate touch events on the phone.

I have already tried this methods:

  • adb : adb swipe and s
相关标签:
2条回答
  • 2021-01-29 03:06

    I would like to find a way to achieve this in a single application which can produce touch outside of the app (from background) and I would like to publish on market.

    This is not possible, outside of what little input faking can be done by an accessibility service.

    How and with what privileges can teamviewer do it?

    If your read that Play Store listing, you will notice that it only works with Samsung devices. That is because the makers of TeamViewer struck a deal with Samsung to enable this sort of integration. Similarly, the TeamViewer team struck deals with a few other device manufacturers. However, they did not do so with all manufacturers, and so TeamViewer does not work on all devices.

    0 讨论(0)
  • 2021-01-29 03:08

    Have a look here .This might be useful.

    InputInjector Android library that eases the process of injecting InputEvents (MotionEvent, KeyEvent) to you Android app. The library uses internal API calls to inject events and depend on the accessability of these. This library will therefore not work on all devices but theoretically support Android 2.3 and forward (API level 9-18+).

    Androd 2.3 (API level 9-15)

    In older versions of Android we envoke the same system calls as used by the Instrumentation framework.

    Permission No special permission needs to be set.

    Androd 4.1.2 (API level 16 and forward)

    As of API level 16 we have access to the InputManager class. We use this as the basis for the input injection.

    Permission Using InputManager for injection requires setting permission android.permission.INJECT_EVENTS in your manifest.

    Using this permission may require altering Lint Error Checking in order to be able to compile. In Eclipse this is done by going to Window->Preferences->Android->Lint Error Checking and then finding ProtectedPermissions and setting severity to something else than error.

    NOTE: In order to inject events to other apps using InputManager, your apk must be signed with system level certificate.

    https://github.com/arnebp/android-inputinjector

    0 讨论(0)
提交回复
热议问题