chicken_dy/Assets/TKGSDK/UnitySDK/Scripts/AnalyticsScripts/SDKInnerScripts/TGAndroidAnalytics.cs

91 lines
2.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Runtime.InteropServices;
using System;
//Tenjin巨量 事件上报
public class TGAndroidAnalytics
{
private AndroidJavaObject jo;
private static TGAndroidAnalytics _instance;
public static TGAndroidAnalytics Instance
{
get{
if (_instance == null)
{
_instance = new TGAndroidAnalytics();
}
return _instance;
}
}
public TGAndroidAnalytics()
{
using (AndroidJavaClass jc = new AndroidJavaClass("com.toukagames.common.event.AnalyticsManager"))
{
jo = jc.CallStatic<AndroidJavaObject>("getInstance");
}
}
public void onEvent(string event1)
{
SDKCall("onEvent",event1);
}
public void onEvent(string eventId, string value)
{
SDKCall("onEvent",eventId,value);
}
public void onEvent(string eventId, Dictionary<string, string> _eventDic)
{
SDKCall("onEvent", eventId, _eventDic);
}
public void onEvent(string eventId, string _key01, string _value01, string _key02, string _value02)
{
SDKCall("onEvent",eventId,_key01, _value01, _key02, _value02);
}
public int getInt(string key, int def)
{
return SDKCall<int>("getInt",key,def);
}
public string getString(string key, string def)
{
return SDKCall<string>("getString", key, def);
}
public bool getBool(string key, bool def)
{
return SDKCall<bool>("getBool", key, def);
}
private T SDKCall<T>(string method, params object[] param)
{
try
{
return jo.Call<T>(method, param);
}
catch (Exception e)
{
Debug.LogError(e);
}
return default(T);
}
private void SDKCall(string method, params object[] param)
{
try
{
jo.Call(method, param);
}
catch (Exception e)
{
Debug.LogError(e);
}
}
}