本文整理汇总了C#中UnityEngine.AndroidJavaObject.GetRawClass方法的典型用法代码示例。如果您正苦于以下问题:C# AndroidJavaObject.GetRawClass方法的具体用法?C# AndroidJavaObject.GetRawClass怎么用?C# AndroidJavaObject.GetRawClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.AndroidJavaObject
的用法示例。
在下文中一共展示了AndroidJavaObject.GetRawClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Awake
void Awake()
{
#if UNITY_ANDROID && ENABLE_PLUGIN
android = new AndroidJavaObject(ObjectClassPath);
android.Call("init", gameObject.name, "FacebookAgentReceiveAgentEvent");
logMapObject = new AndroidJavaObject("android.os.Bundle");
logMethodID = AndroidJNIHelper.GetMethodID(logMapObject.GetRawClass(), "putString",
"(Ljava/lang/String;Ljava/lang/String;)V");
logClearID = AndroidJNIHelper.GetMethodID(logMapObject.GetRawClass(), "clear", "()V");
logMethodByteArray = AndroidJNIHelper.GetMethodID(logMapObject.GetRawClass(), "putByteArray",
"(Ljava/lang/String;[B)V");
#endif
_instance = this;
}
示例2: logEvent
public void logEvent(string eventId, Dictionary<string, string> parameters)
{
using(AndroidJavaObject obj_HashMap = new AndroidJavaObject("java.util.HashMap"))
{
// Call 'put' via the JNI instead of using helper classes to avoid:
// "JNI: Init'd AndroidJavaObject with null ptr!"
IntPtr method_Put = AndroidJNIHelper.GetMethodID(obj_HashMap.GetRawClass(), "put",
"(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
object[] args = new object[2];
foreach(KeyValuePair<string, string> kvp in parameters)
{
using(AndroidJavaObject k = new AndroidJavaObject("java.lang.String", kvp.Key))
{
using(AndroidJavaObject v = new AndroidJavaObject("java.lang.String", kvp.Value))
{
args[0] = k;
args[1] = v;
AndroidJNI.CallObjectMethod(obj_HashMap.GetRawObject(),
method_Put, AndroidJNIHelper.CreateJNIArgArray(args));
}
}
}
cls_FlurryAgent.CallStatic("logEvent", eventId, obj_HashMap);
}
}
示例3: graphRequest
// Calls a custom Graph API method with the key/value pairs in the Dictionary. Pass in a null dictionary if no parameters are needed.
public static void graphRequest( string graphPath, string httpMethod, Dictionary<string,string> parameters )
{
if( Application.platform != RuntimePlatform.Android )
return;
// load up the Bundle
using( var bundle = new AndroidJavaObject( "android.os.Bundle" ) )
{
var putStringMethod = AndroidJNI.GetMethodID( bundle.GetRawClass(), "putString", "(Ljava/lang/String;Ljava/lang/String;)V" );
var args = new object[2];
// add all our dictionary elements into the Bundle
if( parameters != null )
{
foreach( var kv in parameters )
{
args[0] = new AndroidJavaObject( "java.lang.String", kv.Key );
args[1] = new AndroidJavaObject( "java.lang.String", kv.Value );
AndroidJNI.CallObjectMethod( bundle.GetRawObject(), putStringMethod, AndroidJNIHelper.CreateJNIArgArray( args ) );
}
}
// call off to java land
_facebookPlugin.Call( "graphRequest", graphPath, httpMethod, bundle );
}
}
示例4: CreateJavaHashMap
private AndroidJavaObject CreateJavaHashMap(Dictionary<string, string> storeKeys)
{
var j_HashMap = new AndroidJavaObject("java.util.HashMap");
IntPtr method_Put = AndroidJNIHelper.GetMethodID(j_HashMap.GetRawClass(), "put",
"(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
if (storeKeys != null)
{
object[] args = new object[2];
foreach (KeyValuePair<string, string> kvp in storeKeys)
{
using (AndroidJavaObject k = new AndroidJavaObject("java.lang.String", kvp.Key))
{
using (AndroidJavaObject v = new AndroidJavaObject("java.lang.String", kvp.Value))
{
args[0] = k;
args[1] = v;
AndroidJNI.CallObjectMethod(j_HashMap.GetRawObject(),
method_Put, AndroidJNIHelper.CreateJNIArgArray(args));
}
}
}
}
return j_HashMap;
}
示例5: trackEvent
public static void trackEvent(string eventStr, Hashtable chnlDetail)
{
using (AndroidJavaObject androidJavaObject = new AndroidJavaObject("java.util.HashMap", new object[0]))
{
IntPtr methodID = AndroidJNIHelper.GetMethodID(androidJavaObject.GetRawClass(), "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
object[] array = new object[2];
foreach (DictionaryEntry dictionaryEntry in chnlDetail)
{
using (AndroidJavaObject androidJavaObject2 = new AndroidJavaObject("java.lang.String", new object[]
{
dictionaryEntry.Key
}))
{
using (AndroidJavaObject androidJavaObject3 = new AndroidJavaObject("java.lang.String", new object[]
{
dictionaryEntry.Value
}))
{
array[0] = androidJavaObject2;
array[1] = androidJavaObject3;
AndroidJNI.CallObjectMethod(androidJavaObject.GetRawObject(), methodID, AndroidJNIHelper.CreateJNIArgArray(array));
}
}
}
AdvertMgr.callSdkApi("trackEvent", new object[]
{
eventStr,
androidJavaObject
});
}
}
示例6: dictionaryToHashmap
//helpers
public static AndroidJavaObject dictionaryToHashmap(Dictionary<string, string> dict)
{
AndroidJavaObject hashmap = new AndroidJavaObject("java.util.HashMap");
System.IntPtr methodPut = AndroidJNIHelper.GetMethodID(hashmap.GetRawClass(), "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
object[] args = new object[2];
foreach(KeyValuePair<string, string> kvp in dict) {
AndroidJavaObject k = new AndroidJavaObject("java.lang.String", kvp.Key);
AndroidJavaObject v = new AndroidJavaObject("java.lang.String", kvp.Value);
args[0] = k;
args[1] = v;
AndroidJNI.CallObjectMethod(hashmap.GetRawObject(), methodPut, AndroidJNIHelper.CreateJNIArgArray(args));
}
return hashmap;
}
示例7: OnEvent
public static void OnEvent(string actionId, Dictionary<string, object> parameters)
{
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor && parameters != null && parameters.Count > 0 && parameters.Count <= 10)
{
int count = parameters.Count;
AndroidJavaObject androidJavaObject = new AndroidJavaObject("java.util.HashMap", new object[]
{
count
});
IntPtr methodID = AndroidJNIHelper.GetMethodID(androidJavaObject.GetRawClass(), "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
object[] array = new object[2];
foreach (KeyValuePair<string, object> current in parameters)
{
array[0] = new AndroidJavaObject("java.lang.String", new object[]
{
current.Key
});
if (typeof(string).IsInstanceOfType(current.Value))
{
array[1] = new AndroidJavaObject("java.lang.String", new object[]
{
current.Value
});
}
else
{
array[1] = new AndroidJavaObject("java.lang.Double", new object[]
{
string.Empty + current.Value
});
}
AndroidJNI.CallObjectMethod(androidJavaObject.GetRawObject(), methodID, AndroidJNIHelper.CreateJNIArgArray(array));
}
if (TalkingDataGA.agent != null)
{
AndroidJavaObject @static = TalkingDataGA.unityClass.GetStatic<AndroidJavaObject>("currentActivity");
TalkingDataGA.agent.CallStatic("onEvent", new object[]
{
@static,
actionId,
androidJavaObject
});
}
}
}
示例8: init
public void init(Dictionary<string, string> storeKeys=null) {
if (!IsDevice()) return;
using (AndroidJavaObject obj_HashMap = new AndroidJavaObject("java.util.HashMap")) {
IntPtr method_Put = AndroidJNIHelper.GetMethodID(obj_HashMap.GetRawClass(), "put",
"(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
if (storeKeys != null) {
object[] args = new object[2];
foreach (KeyValuePair<string, string> kvp in storeKeys) {
using (AndroidJavaObject k = new AndroidJavaObject("java.lang.String", kvp.Key)) {
using (AndroidJavaObject v = new AndroidJavaObject("java.lang.String", kvp.Value)) {
args[0] = k;
args[1] = v;
AndroidJNI.CallObjectMethod(obj_HashMap.GetRawObject(),
method_Put, AndroidJNIHelper.CreateJNIArgArray(args));
}
}
}
}
_plugin.Call("init", obj_HashMap);
}
}
示例9: init
public void init(Options options)
{
if (!IsDevice())
{
// Fake init process in the editor. For test purposes
OpenIAB.EventManager.SendMessage("OnBillingSupported", "");
return;
}
using (var j_optionsBuilder = new AndroidJavaObject("org.onepf.oms.OpenIabHelper$Options$Builder"))
{
var clazz = j_optionsBuilder.GetRawClass();
var objPtr = j_optionsBuilder.GetRawObject();
j_optionsBuilder.Call<AndroidJavaObject>("setDiscoveryTimeout", options.discoveryTimeoutMs)
.Call<AndroidJavaObject>("setCheckInventory", options.checkInventory)
.Call<AndroidJavaObject>("setCheckInventoryTimeout", options.checkInventoryTimeoutMs)
.Call<AndroidJavaObject>("setVerifyMode", (int) options.verifyMode);
foreach (var pair in options.storeKeys)
j_optionsBuilder.Call<AndroidJavaObject>("addStoreKey", pair.Key, pair.Value);
var addPreferredStoreNameMethod = AndroidJNI.GetMethodID(clazz, "addPreferredStoreName", "([Ljava/lang/String;)Lorg/onepf/oms/OpenIabHelper$Options$Builder;");
var prms = new jvalue[1];
prms[0].l = AndroidJNIHelper.ConvertToJNIArray(options.prefferedStoreNames);
AndroidJNI.CallObjectMethod(objPtr, addPreferredStoreNameMethod, prms);
// Build options instance
var buildMethod = AndroidJNI.GetMethodID(clazz, "build", "()Lorg/onepf/oms/OpenIabHelper$Options;");
var j_options = AndroidJNI.CallObjectMethod(objPtr, buildMethod, new jvalue[0]);
// UnityPlugin.initWithOptions(OpenIabHelper.Options options);
var initWithOptionsMethod = AndroidJNI.GetMethodID(_plugin.GetRawClass(), "initWithOptions", "(Lorg/onepf/oms/OpenIabHelper$Options;)V");
prms = new jvalue[1];
prms[0].l = j_options;
AndroidJNI.CallVoidMethod(_plugin.GetRawObject(), initWithOptionsMethod, prms);
}
}
示例10: IsAndroidJavaObjectNull
private static bool IsAndroidJavaObjectNull(AndroidJavaObject androidJavaObject) {
return androidJavaObject == null ||
androidJavaObject.GetRawClass().ToInt32() == 0;
}
示例11: trackRichEvent
public static void trackRichEvent(string eventName, Dictionary<string, string> eventValues){
using(AndroidJavaObject obj_HashMap = new AndroidJavaObject("java.util.HashMap"))
{
IntPtr method_Put = AndroidJNIHelper.GetMethodID(obj_HashMap.GetRawClass(), "put",
"(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
object[] args = new object[2];
foreach(KeyValuePair<string, string> kvp in eventValues)
{
using(AndroidJavaObject k = new AndroidJavaObject("java.lang.String", kvp.Key))
{
using(AndroidJavaObject v = new AndroidJavaObject("java.lang.String", kvp.Value))
{
args[0] = k;
args[1] = v;
AndroidJNI.CallObjectMethod(obj_HashMap.GetRawObject(),
method_Put, AndroidJNIHelper.CreateJNIArgArray(args));
}
}
}
using(AndroidJavaClass cls_UnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
{
using(AndroidJavaObject cls_Activity = cls_UnityPlayer.GetStatic<AndroidJavaObject>("currentActivity"))
{
cls_AppsFlyer.CallStatic("trackEvent",cls_Activity, eventName, obj_HashMap);
}
}
}
}
示例12: makeJNICall
void makeJNICall(PickerType type, string[] items, long selectedItem)
{
if (isMobileRuntime == false) {
return;
}
#if UNITY_ANDROID
AndroidJavaObject obj_ArrayListItems = new AndroidJavaObject("java.util.ArrayList");
IntPtr method_Add = AndroidJNIHelper.GetMethodID(obj_ArrayListItems.GetRawClass(), "add", "(Ljava/lang/Object;)Z");
foreach (string item in items) {
AndroidJNI.CallBooleanMethod(obj_ArrayListItems.GetRawObject(), method_Add, AndroidJNIHelper.CreateJNIArgArray(new string[] {item}));
}
Debug.Log(String.Format("Selected item -> {0}", selectedItem));
_pluginObject.Call("showPicker", (int)type, obj_ArrayListItems, selectedItem, "NativePicker");
#else
return;
#endif
}
示例13: StartVideoPlayerOnTextureId
/// <summary>
/// Set up the video player with the movie surface texture id
/// </summary>
void StartVideoPlayerOnTextureId()
{
int textureId = nativeTextureID;
Debug.Log("SetUpVideoPlayer ");
//IntPtr androidSurface = OVR_Media_Surface( textureId, 2880, 1440 );
IntPtr androidSurface = OVR_Media_Surface( textureId, 1920, 1080 );
mediaPlayer = new AndroidJavaObject("android/media/MediaPlayer");
// Can't use AndroidJavaObject.Call() with a jobject, must use low level interface
//mediaPlayer.Call("setSurface", androidSurface);
IntPtr setSurfaceMethodId = AndroidJNI.GetMethodID(mediaPlayer.GetRawClass(),"setSurface","(Landroid/view/Surface;)V");
jvalue[] parms = new jvalue[1];
parms[0] = new jvalue();
parms[0].l = androidSurface;
AndroidJNI.CallObjectMethod(mediaPlayer.GetRawObject(), setSurfaceMethodId, parms);
mediaPlayer.Call("setDataSource", "/storage/extSdCard/Oculus/zurichvideos/" + videoName);
//mediaPlayer.Call("setDataSource", "/storage/sdcard0/zurichvideos/" + videoName);
mediaPlayer.Call("prepare");
mediaPlayer.Call("setLooping", false);
mediaPlayer.Call("start");
//return mediaPlayer;
}
示例14: Read
int Read(AndroidJavaObject javaObject, byte[] buffer, int offset, int count)
{
var args = new object[]{buffer, offset, count};
IntPtr methodID = AndroidJNIHelper.GetMethodID<int>(javaObject.GetRawClass(), "read", args, false);
jvalue[] array = AndroidJNIHelper.CreateJNIArgArray(args);
try
{
var readLen = AndroidJNI.CallIntMethod(javaObject.GetRawObject(), methodID, array);
if (readLen > 0)
{
var temp = AndroidJNI.FromByteArray(array[0].l);
Array.Copy(temp, offset, buffer, offset, readLen);
}
return readLen;
}
finally
{
AndroidJNIHelper.DeleteJNIArgArray(args, array);
}
}
示例15: Track
public void Track(string _namespace, string name, Dictionary<string, string> properties, GrowthAnalytics.TrackOption option)
{
using (AndroidJavaObject hashMap = new AndroidJavaObject("java.util.HashMap"))
{
System.IntPtr method_Put = AndroidJNIHelper.GetMethodID (hashMap.GetRawClass (), "put",
"(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
object[] args = new object[2];
foreach (KeyValuePair<string, string> kvp in properties)
{
using (AndroidJavaObject k = new AndroidJavaObject("java.lang.String", kvp.Key))
{
using (AndroidJavaObject v = new AndroidJavaObject("java.lang.String", kvp.Value))
{
args [0] = k;
args [1] = v;
AndroidJNI.CallObjectMethod (hashMap.GetRawObject (),
method_Put, AndroidJNIHelper.CreateJNIArgArray (args));
}
}
}
AndroidJavaClass growthAnalyticsClass = new AndroidJavaClass( "com.growthbeat.analytics.GrowthAnalytics$TrackOption" );
AndroidJavaObject optionObject = growthAnalyticsClass.GetStatic<AndroidJavaObject>(option == GrowthAnalytics.TrackOption.TrackOptionOnce ? "ONCE" : "COUNTER");
growthAnalytics.Call("track", _namespace, name, hashMap, optionObject, null);
}
}