Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想创建一个活动监视器程序来监视指定的活动及其事件。
您能告诉我如何知道正在执行的活动中的哪个事件吗?如何在同一活动中收集与点击或滑动相关的数据,即点击了哪个按钮或菜单。
您可以使用以下方法获取正在运行的活动名称 -
this.getClass().getSimpleName()
我多次使用上述代码在我的应用程序中查找正在运行的活动名称。
尝试下面的代码来查找按下的按钮信息,
public void onClick(View view) { Button b1 = (Button)view; String text = b1.getText().toString(); }