android - 实现一个库来跟踪应用程序中的所有事件

标签 android

我正在尝试创建一个库,我们称它为 L。假设 A 公司有一个 Android 应用程序。

L 可以链接到 A,这样在 A 的代码中,开发人员只需添加如下内容:

L l = new L("client_id") l.startTrack();

现在 L 应该能够跟踪 A 中发生的所有点击并传递给服务器进行记录。 AppSee 是一款已经在这样做的产品。

我想知道如何拦截每个用户操作以获取操作目标名称(按钮标题?文本字段?)

谢谢!

最佳答案

你问的是 EventTracking,就像在 GoogleAnalytics 中一样。但是你正在做的方法是不同的。在谷歌分析中,需要启动事件到事件跟踪器。比如说你有 3 个按钮,你需要分别跟踪每个按钮,在那里你放了 3 个单独的事件跟踪器。

如果您想跟踪 Activity 中发生的所有事件,您需要实现 Activity 的 onInterceptTouchEvent()。每当 Activity 中发生触摸事件时,它都会通过上述方法。

正如谷歌所说

Implement this method to intercept all touch screen motion events. This allows you to watch events as they are dispatched to your children, and take ownership of the current gesture at any point.

小心

Using this function takes some care, as it has a fairly complicated interaction with View.onTouchEvent(MotionEvent), and using it requires implementing that method as well as this one in the correct way.

更多 Activity 详情,look here .

关于android - 实现一个库来跟踪应用程序中的所有事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33303339/

相关文章:

android - 应用程序 :showAsAction ="always|withText" not showing text

java - Android 访问使用 -e 发送的数据

java - 三星 s8 和 s9 中的 Android 外部写入权限问题

android - 服务——为共享首选项声明静态字符串的最佳位置

android - 如何在布局之上绘制

android - 如何从房间数据库中的位置对象保存和检索纬度和经度

java - 无法从 AlarmManager 取消 PendingIntent

android - 如何在 Oreo 中创建下载进度通知?

android - 如何在 android 2.0 的联系人中添加自定义数据/字段?

android - 我可以检测到我的 Android 应用程序的特定权限已被删除吗?