Android Open Source - countly-sdk-android Open U D I D Adapter






From Project

Back to project page countly-sdk-android.

License

The source code is released under:

Copyright (c) 2012, 2013 Countly Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Soft...

If you think the Android project countly-sdk-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package ly.count.android.api;
//  www.  ja  v a2  s.com
import android.content.Context;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class OpenUDIDAdapter {
    private final static String OPEN_UDID_MANAGER_CLASS_NAME = "org.OpenUDID.OpenUDID_manager";

    public static boolean isOpenUDIDAvailable() {
        boolean openUDIDAvailable = false;
        try {
            Class.forName(OPEN_UDID_MANAGER_CLASS_NAME);
            openUDIDAvailable = true;
        }
        catch (ClassNotFoundException ignored) {}
        return openUDIDAvailable;
    }

    public static boolean isInitialized() {
        boolean initialized = false;
        try {
            final Class<?> cls = Class.forName(OPEN_UDID_MANAGER_CLASS_NAME);
            final Method isInitializedMethod = cls.getMethod("isInitialized", (Class[]) null);
            final Object result = isInitializedMethod.invoke(null, (Object[]) null);
            if (result instanceof Boolean) {
                initialized = (Boolean) result;
            }
        }
        catch (ClassNotFoundException ignored) {}
        catch (NoSuchMethodException ignored) {}
        catch (InvocationTargetException ignored) {}
        catch (IllegalAccessException ignored) {}
        return initialized;
    }

    public static void sync(final Context context) {
        try {
            final Class<?> cls = Class.forName(OPEN_UDID_MANAGER_CLASS_NAME);
            final Method syncMethod = cls.getMethod("sync", Context.class);
            syncMethod.invoke(null, context);
        }
        catch (ClassNotFoundException ignored) {}
        catch (NoSuchMethodException ignored) {}
        catch (InvocationTargetException ignored) {}
        catch (IllegalAccessException ignored) {}
    }

    public static String getOpenUDID() {
        String openUDID = null;
        try {
            final Class<?> cls = Class.forName(OPEN_UDID_MANAGER_CLASS_NAME);
            final Method getOpenUDIDMethod = cls.getMethod("getOpenUDID", (Class[]) null);
            final Object result = getOpenUDIDMethod.invoke(null, (Object[]) null);
            if (result instanceof String) {
                openUDID = (String) result;
            }
        }
        catch (ClassNotFoundException ignored) {}
        catch (NoSuchMethodException ignored) {}
        catch (InvocationTargetException ignored) {}
        catch (IllegalAccessException ignored) {}
        return openUDID;
    }
}




Java Source Code List

ly.count.android.api.AdvertisingIdAdapter.java
ly.count.android.api.ConnectionProcessor.java
ly.count.android.api.ConnectionQueue.java
ly.count.android.api.CountlyStore.java
ly.count.android.api.Countly.java
ly.count.android.api.DeviceId.java
ly.count.android.api.DeviceInfo.java
ly.count.android.api.EventQueue.java
ly.count.android.api.Event.java
ly.count.android.api.OpenUDIDAdapter.java
ly.count.android.api.UserData.java
ly.count.android.example.CountlyActivity.java
org.OpenUDID.OpenUDID_manager.java
org.OpenUDID.OpenUDID_service.java