安卓触摸跟踪

标签 android

我有一个主要 Activity ,以及许多扩展主要 Activity 的其他 Activity 。我想跟踪子 Activity 中的所有触摸事件,如单击按钮、 ListView 项、textView..等。但我无法做到这一点。我在主要 Activity 中实现了 onTouchEvent(MotionEvent 事件),

@Override
onTouchEvent(MotionEvent event)
     public boolean onTouchEvent(MotionEvent event) {
            System.out.println("onTouchEvent pressed");
            return super.onTouchEvent(event);
        }

但是这个函数没有被调用..有什么想法吗?

最佳答案

看看https://github.com/commonsguy/cw-advandroid/blob/master/Tapjacking/Jackalope/src/com/commonsware/android/tj/jackalope/Tapjacker.java.

它是一个为窗口管理器添加透明View的服务。该服务还实现了一个 onTouchListener。监听器将在应用运行时跟踪所有触摸事件。

它可能是最容易实现的,并且提供了一个中心位置来跟踪触摸事件。

关于安卓触摸跟踪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6689990/

相关文章:

Android 市场崩溃报告未报告 bugsense

Android Listview 回收是带动画行的

android - android 2.1 中的 AlertDialog

java - ListFragment 类中的 DragSortListView 库和 DropListener

android - 将我的 TTS 引擎添加到像 SAPI 一样的 Android TTS 服务

android - 来自房间数据库的数据不会显示在回收站 View 中。可能出了什么问题?

android - 是否有理由继续使用 IntentService 来处理 GCM 消息?

android - 从布局中移除子项

Android Test Orchestrator 和自定义应用程序类

android - 从应用程序调用默认主屏幕