gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:27:06 25 4
gpt4 key购买 nike

我正在尝试创建一个库,我们称它为 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com