如何在 Android Google Analytics V4 中获取 clientId? [英] How to get clientId in Android Google Analytics V4?

查看:26
本文介绍了如何在 Android Google Analytics V4 中获取 clientId?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Android 中获取自动设置的 Analytics clientId.(Android API 文档中将其设置解释为 setClientId())

I am trying to get the automatically set Analytics clientId in Android. (Setting it is explained in the Android API documentation as setClientId())

当我尝试使用 tracker.get("clientId") 时,它返回空.有人知道吗?

When I try to use tracker.get("clientId") it returns empty. Any idea anyone?

提前致谢!

推荐答案

我已经为您运行了一个反编译器,似乎 clientId 属性与键&cid"一起存储.

I've ran a decompiler on it for you and it seems like the clientId property is stored with the key "&cid".

它在内部是这样做的:

set("&cid", clientId);

解决方案是这样调用:

tracker.get("&cid");

get() 方法对客户端 ID 键有特殊的逻辑.它还可能返回一个新生成的密钥或抛出一个 InterruptedException 像ClientId 加载或生成被中断"或 ExecutionException无法加载或生成客户端 ID"

The get() method does however have special logic for the client ID key. It might also return a newly generated key or throw an InterruptedException like "ClientId loading or generation was interrupted" or an ExecutionException "Failed to load or generate client id"

您可以在 Android Studio(或 IntelliJ IDEA)中通过安装Java Bytecode Decompiler"或Java Decompiler IntelliJ Plugin"插件自行解决此类问题.这允许您找到 Tracker.class 符号并将其视为 Java 常规文件.

You can solve these kinds of issues yourself in Android Studio (or IntelliJ IDEA) by installing the "Java Bytecode Decompiler" or "Java Decompiler IntelliJ Plugin" plugins. This allows you to find the Tracker.class symbol and view it as if it was a Java regular file.

这篇关于如何在 Android Google Analytics V4 中获取 clientId?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆