91 lines
2.0 KiB
C#
91 lines
2.0 KiB
C#
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);
|
||
}
|
||
}
|
||
} |