Giter Club home page Giter Club logo

Comments (8)

stevenwsg avatar stevenwsg commented on May 28, 2024

我看oaid也只有DeviceID.register(this);赋值,在没有其他地方赋值了,其他地方都是读取。

from android_cn_oaid.

liyujiang-gzu avatar liyujiang-gzu commented on May 28, 2024

我看oaid也只有DeviceID.register(this);赋值,在没有其他地方赋值了,其他地方都是读取。

DeviceID.register(this);这种用法,建议在Application里预先获取。不然就每次都调用DeviceID.getOAID(this, new IGetter() {..});适时获取。由于DeviceID.getOAID(this, new IGetter() {..});是异步的,你的这种为空的情况可能是DeviceID.register(this);里调用getOAID的时候还在获取OAID的过程中还没等得到结果就已经开始上报数据了

from android_cn_oaid.

stevenwsg avatar stevenwsg commented on May 28, 2024

我看oaid也只有DeviceID.register(this);赋值,在没有其他地方赋值了,其他地方都是读取。

DeviceID.register(this);这种用法,建议在Application里预先获取。不然就每次都调用DeviceID.getOAID(this, new IGetter() {..});适时获取。由于DeviceID.getOAID(this, new IGetter() {..});是异步的,你的这种为空的情况可能是DeviceID.register(this);里调用getOAID的时候还在获取OAID的过程中还没等得到结果就已经开始上报数据了

目前DeviceID.register(this);是在Application的oncreate中预期的。
获取oaid具体的时间最长会有多长时间啊? 数据反馈这个埋点上报的时机至少是APP启动了一定时间的

from android_cn_oaid.

liyujiang-gzu avatar liyujiang-gzu commented on May 28, 2024

我看oaid也只有DeviceID.register(this);赋值,在没有其他地方赋值了,其他地方都是读取。

DeviceID.register(this);这种用法,建议在Application里预先获取。不然就每次都调用DeviceID.getOAID(this, new IGetter() {..});适时获取。由于DeviceID.getOAID(this, new IGetter() {..});是异步的,你的这种为空的情况可能是DeviceID.register(this);里调用getOAID的时候还在获取OAID的过程中还没等得到结果就已经开始上报数据了

目前DeviceID.register(this);是在Application的oncreate中预期的。
获取oaid具体的时间最长会有多长时间啊? 数据反馈这个埋点上报的时机至少是APP启动了一定时间的

OAID的获取时长有点无法预计,不同的厂商和品牌实现方式不一样。为了保证OIAD不为空,也许你可以参照DeviceID.register(this);里的写法,等到getOAID得到回调onOAIDGetComplete或者onOAIDGetError后再上报数据:

       String uniqueID = getUniqueID(application);
        if (!TextUtils.isEmpty(uniqueID)) {
            instance.clientId = uniqueID;
            OAIDLog.print("Client id is IMEI/MEID: " + instance.clientId);
            return;
        }
        getOAID(application, this);

    @Override
    public void onOAIDGetComplete(String result) {
        if (result == null) {
            result = "";
        }
        clientId = result;
        oaid = result;
        OAIDLog.print("Client id is OAID/AAID: " + clientId);
    }

    @Override
    public void onOAIDGetError(Exception error) {
        String id = DeviceID.getWidevineID();
        if (!TextUtils.isEmpty(id)) {
            clientId = id;
            OAIDLog.print("Client id is WidevineID: " + clientId);
            return;
        }
        id = getAndroidID(application);
        if (!TextUtils.isEmpty(id)) {
            clientId = id;
            OAIDLog.print("Client id is AndroidID: " + clientId);
            return;
        }
        clientId = getGUID(application);
        OAIDLog.print("Client id is GUID: " + clientId);
    }

from android_cn_oaid.

liyujiang-gzu avatar liyujiang-gzu commented on May 28, 2024

没注意onOAIDGetComplete(String result)result还可能为空,除了上面说的可能是getOAID还没得到回调就开始上报数据了,不知道会不会是本身获取OAID就是空的?说不定还真是有时候onOAIDGetComplete拿到的OAID就是空的

from android_cn_oaid.

stevenwsg avatar stevenwsg commented on May 28, 2024

我看oaid也只有DeviceID.register(this);赋值,在没有其他地方赋值了,其他地方都是读取。

DeviceID.register(this);这种用法,建议在Application里预先获取。不然就每次都调用DeviceID.getOAID(this, new IGetter() {..});适时获取。由于DeviceID.getOAID(this, new IGetter() {..});是异步的,你的这种为空的情况可能是DeviceID.register(this);里调用getOAID的时候还在获取OAID的过程中还没等得到结果就已经开始上报数据了

目前DeviceID.register(this);是在Application的oncreate中预期的。
获取oaid具体的时间最长会有多长时间啊? 数据反馈这个埋点上报的时机至少是APP启动了一定时间的

OAID的获取时长有点无法预计,不同的厂商和品牌实现方式不一样。为了保证OIAD不为空,也许你可以参照DeviceID.register(this);里的写法,等到getOAID得到回调onOAIDGetComplete或者onOAIDGetError后再上报数据:

       String uniqueID = getUniqueID(application);
        if (!TextUtils.isEmpty(uniqueID)) {
            instance.clientId = uniqueID;
            OAIDLog.print("Client id is IMEI/MEID: " + instance.clientId);
            return;
        }
        getOAID(application, this);

    @Override
    public void onOAIDGetComplete(String result) {
        if (result == null) {
            result = "";
        }
        clientId = result;
        oaid = result;
        OAIDLog.print("Client id is OAID/AAID: " + clientId);
    }

    @Override
    public void onOAIDGetError(Exception error) {
        String id = DeviceID.getWidevineID();
        if (!TextUtils.isEmpty(id)) {
            clientId = id;
            OAIDLog.print("Client id is WidevineID: " + clientId);
            return;
        }
        id = getAndroidID(application);
        if (!TextUtils.isEmpty(id)) {
            clientId = id;
            OAIDLog.print("Client id is AndroidID: " + clientId);
            return;
        }
        clientId = getGUID(application);
        OAIDLog.print("Client id is GUID: " + clientId);
    }

嗯嗯 谢谢我试试~

from android_cn_oaid.

stevenwsg avatar stevenwsg commented on May 28, 2024

没注意onOAIDGetComplete(String result)result还可能为空,除了上面说的可能是getOAID还没得到回调就开始上报数据了,不知道会不会是本身获取OAID就是空的?说不定还真是有时候onOAIDGetComplete拿到的OAID就是空的

嗯嗯 就是存在可能同一个设备,有时能获取到oaid,有时获取不到。 有这种概率是吧

from android_cn_oaid.

liyujiang-gzu avatar liyujiang-gzu commented on May 28, 2024

没注意onOAIDGetComplete(String result)result还可能为空,除了上面说的可能是getOAID还没得到回调就开始上报数据了,不知道会不会是本身获取OAID就是空的?说不定还真是有时候onOAIDGetComplete拿到的OAID就是空的

嗯嗯 就是存在可能同一个设备,有时能获取到oaid,有时获取不到。 有这种概率是吧

自4.2.6版本开始已暴露一个回调接口IRegisterCallback,埋点上报可以改到这个回调接口里。

from android_cn_oaid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.