public static string CheckReward()
    {
        #if UNITY_IPHONE && !UNITY_EDITOR
        return UnityShimOAD_CheckReward ();
        #endif
        #if UNITY_ANDROID
        AndroidJavaClass oadClass = new AndroidJavaClass("com.openadadapter.OpenAdAdapter");
        if (oadClass != null){

            bool b1 = oadClass.CallStatic<bool>("hasReward");

            if(!b1){
                return null;
            }

            AndroidJavaClass rwdClass = new AndroidJavaClass("com.openadadapter.Reward");
            if(rwdClass != null){
                AndroidJavaObject r1 = oadClass.CallStatic<AndroidJavaObject>("fetchReward");
                if (r1.GetRawObject().ToInt32() == 0){
                    return null;
                }
                //		float height = oadClass.CallStatic<float>("getBannerHeightInPoints");
                float amount = r1.Call<float>("getAmount");
                string network = r1.Call<string>("getNetwork");
                string currency = r1.Call<string>("getCurrency");

                return "amount\t" + amount + "\nnetwork\t" + network + "\ncurrency\t" + currency;
            }
        }
        #endif
        return null;
    }
Example #2
0
			static public bool ForceLoadLowLevelBinary()
			{
				// This is a hack that forces Android to load the .so libraries in the correct order
#if UNITY_ANDROID && !UNITY_EDITOR
				FMOD.Studio.UnityUtil.Log("loading binaries: " + FMOD.Studio.STUDIO_VERSION.dll + " and " + FMOD.VERSION.dll);
				AndroidJavaClass jSystem = new AndroidJavaClass("java.lang.System");
				jSystem.CallStatic("loadLibrary", FMOD.VERSION.dll);
				jSystem.CallStatic("loadLibrary", FMOD.Studio.STUDIO_VERSION.dll);
#endif

				// Hack: force the low level binary to be loaded before accessing Studio API
#if !UNITY_IPHONE || UNITY_EDITOR
				FMOD.Studio.UnityUtil.Log("Attempting to call Memory_GetStats");
				int temp1, temp2;
				if (!ERRCHECK(FMOD.Memory.GetStats(out temp1, out temp2)))
				{
					FMOD.Studio.UnityUtil.LogError("Memory_GetStats returned an error");
					return false;
				}
		
				FMOD.Studio.UnityUtil.Log("Calling Memory_GetStats succeeded!");
#endif
		
				return true;
			}
	/// <summary>
	/// Description:
	/// Start Crittercism for Unity, will start crittercism for android if it is not already active.
	/// Parameters:
	/// appID: Crittercisms Provided App ID for this application
	/// </summary>
	public static void Init(string appID, bool bDelay, bool bSendLogcat, string customVersion, string callbackObjectName, string callbackObjectMethod)
	{
#if (UNITY_ANDROID && !UNITY_EDITOR) || FORCE_DEBUG
		try
		{
			_IsPluginInited	= IsInited();
			if(_IsPluginInited && _IsUnityPluginInited)	{	return;	}
			
			if(!_IsUnityPluginInited)
			{
				AndroidJavaClass cls_UnityPlayer	= new AndroidJavaClass("com.unity3d.player.UnityPlayer");
				AndroidJavaObject objActivity		= cls_UnityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
				mCrittercismsPlugin	= new AndroidJavaClass("com.crittercism.unity.CrittercismAndroid");
				if(mCrittercismsPlugin == null)
				{
					CLog("To find Crittercism Plugin");
					throw new System.Exception("ExitError");
				}
				
				mCrittercismsPlugin.CallStatic("SetConfig", bDelay, bSendLogcat, customVersion);
				mCrittercismsPlugin.CallStatic("Init", objActivity, appID, callbackObjectName, callbackObjectMethod);
			}
			
			EnableDebugLog(_ShowDebugOnOnRelease);
		}
		catch(System.Exception e)
		{
			CLog("Failed to initialize Crittercisms: " + e.Message);
			_IsUnityPluginInited	= false;
		}
		CLog(string.Format("Init complete, _IsPluginInited={0}, _IsUnityPluginInited={1}", _IsPluginInited, _IsUnityPluginInited));
#endif
	}
		public static void SendEmail(Email email)
		{
#if UNITY_IOS && !UNITY_EDITOR
			_opencodingConsoleBeginEmail(email.ToAddress, email.Subject, email.Message, email.IsHTML);
			foreach (var attachment in email.Attachments)
			{
				_opencodingConsoleAddAttachment(attachment.Data, attachment.Data.Length, attachment.MimeType, attachment.Filename);
			}
			_opencodingConsoleFinishEmail();
#elif UNITY_ANDROID && !UNITY_EDITOR
			AndroidJavaClass androidEmailClass = new AndroidJavaClass("net.opencoding.console.Email");
			
			androidEmailClass.CallStatic("beginEmail", email.ToAddress, email.Subject, email.Message, email.IsHTML);
			var emailAttachmentsDirectory = Path.Combine(Application.temporaryCachePath, "EmailAttachments");
			Directory.CreateDirectory(emailAttachmentsDirectory);
			foreach (var attachment in email.Attachments)
			{
				var attachmentPath = Path.Combine(emailAttachmentsDirectory, attachment.Filename);
				File.WriteAllBytes(attachmentPath, attachment.Data);
				androidEmailClass.CallStatic("addAttachment", attachmentPath);
			}

			androidEmailClass.CallStatic("finishEmail");
#else
			throw new InvalidOperationException("Emailing is not supported on this platform. Please contact [email protected] and I'll do my best to support it!");
#endif
		}
Example #5
0
 public void OnClickButton()
 {
     using (AndroidJavaClass javaCalss = new AndroidJavaClass("com.example.yoon.lib.NativePlugin"))
     {
         javaCalss.CallStatic("showToast", "Test");
         javaCalss.CallStatic("onCreate");
     }
 }
        public static void OpenShareDialog(string title, string text, Texture2D image = null)
        {
            AndroidJavaClass sharingClass = new AndroidJavaClass("net.agasper.unitysharingplugin.Sharing");
            if (image != null)
            {
                byte[] bytes = image.EncodeToPNG();
                File.WriteAllBytes(sharingClass.CallStatic<string>("GetImagePath"), bytes);
            }

            sharingClass.CallStatic("Share", title, text, image != null ? 1 : 0);
        }
    void InitPushwoosh()
    {
        if(pushwoosh != null)
            return;

        using(var pluginClass = new AndroidJavaClass("com.pushwoosh.PushwooshProxy")) {
            pluginClass.CallStatic("initialize", Pushwoosh.APP_CODE, Pushwoosh.GCM_PROJECT_NUMBER);
            pushwoosh = pluginClass.CallStatic<AndroidJavaObject>("instance");
        }

        pushwoosh.Call("setListenerName", this.gameObject.name);
    }
	void OnApplicationPause (bool pauseStatus){
        if (pauseStatus) {
			plugin.CallStatic("stopIconAd", activity); 
		}else{
	       	unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
			activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
	
			plugin = new AndroidJavaClass("jp.basicinc.gamefeat.android.unity.GameFeatUnityPlugin");
			plugin.CallStatic("activateGF", activity, true, true, true);
			plugin.CallStatic("startIconAd", activity); 
		}
	}	
	protected override void Initialize() 
	{
		if(pushwoosh != null)
			return;
		
		using(var pluginClass = new AndroidJavaClass("com.pushwoosh.PushwooshProxy")) {
		pluginClass.CallStatic("initialize", Pushwoosh.ApplicationCode, Pushwoosh.GcmProjectNumber);
			pushwoosh = pluginClass.CallStatic<AndroidJavaObject>("instance");
		}
		
		pushwoosh.Call("setListenerName", this.gameObject.name);
	}
Example #10
0
        public override void Update()
        {
            if (native.CallStatic <bool>("CheckSaveImageDone"))
            {
                if (streamFileSavedCallback != null)
                {
                    streamFileSavedCallback(native.CallStatic <bool>("CheckSaveImageSucceeded"));
                    streamFileSavedCallback = null;
                }
            }

            if (native.CallStatic <bool>("CheckLoadImageDone"))
            {
                if (streamFileLoadedCallback != null)
                {
                    bool succeeded = native.CallStatic <bool>("CheckLoadImageSucceeded");
                    if (succeeded)
                    {
                        streamFileLoadedCallback(new MemoryStream(native.CallStatic <byte[]>("GetLoadedImageData")), succeeded);
                    }
                    else
                    {
                        streamFileLoadedCallback(null, succeeded);
                    }

                    streamFileLoadedCallback = null;
                }
            }
        }
    public static void Init()
    {
        using (var actClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
        {
            mPlayerActivityContext = actClass.GetStatic<AndroidJavaObject>("currentActivity");
        }

        mBridgeClass = new AndroidJavaClass("jwebview.JWebHelper");
        Debug.Log(mPlayerActivityContext);
        mBridgeClass.CallStatic("SetContext", mPlayerActivityContext);

        mIsReady = true;

        Debug.Log("Test: " + mBridgeClass.CallStatic<string>("WhoAreYou"));
    }
    public void Share(string shareText, string imagePath, string url, string subject = "")
    {
        #if UNITY_ANDROID
        AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent");
        AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent");

        intentObject.Call<AndroidJavaObject>("setAction", intentClass.GetStatic<string>("ACTION_SEND"));
        AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri");
        AndroidJavaObject uriObject = uriClass.CallStatic<AndroidJavaObject>("parse", "file://" + imagePath);
        intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_STREAM"), uriObject);
        intentObject.Call<AndroidJavaObject>("setType", "image/png");

        intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_TEXT"), shareText);

        AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity");

        AndroidJavaObject jChooser = intentClass.CallStatic<AndroidJavaObject>("createChooser", intentObject, subject);
        currentActivity.Call("startActivity", jChooser);
        #elif UNITY_IOS
        CallSocialShareAdvanced(shareText, subject, url, imagePath);
        #else
        Debug.Log("No sharing set up for this platform.");
        #endif
    }
Example #13
0
 public void sendPayUser(string gameUserId, double pay, string productCode, string currency, string market)
 {
     #if UNITY_ANDROID
     AndroidJavaClass statisticsClass = new AndroidJavaClass ("com.naver.glink.android.sdk.Statistics");
     statisticsClass.CallStatic ("sendPayUser", gameUserId, pay, productCode, currency, market);
     #endif
 }
Example #14
0
 public void sendNewUser(string gameUserId, string market)
 {
     #if UNITY_ANDROID
     AndroidJavaClass statisticsClass = new AndroidJavaClass ("com.naver.glink.android.sdk.Statistics");
     statisticsClass.CallStatic ("sendNewUser", gameUserId, market);
     #endif
 }
    IEnumerator Start()
    {
        #if UNITY_IPHONE
        ADBannerView banner = new ADBannerView();
        banner.autoSize = true;
        banner.autoPosition = ADPosition.Bottom;

        while (true) {
            if (banner.error != null) {
                Debug.Log("Error: " + banner.error.description);
                break;
            } else if (banner.loaded) {
                banner.Show();
                break;
            }
            yield return null;
        }
        #elif UNITY_ANDROID && !UNITY_EDITOR
        AndroidJavaClass plugin = new AndroidJavaClass("net.oira_project.adstirunityplugin.AdBannerController");
        AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
        while (true) {
            plugin.CallStatic("tryCreateBanner", activity, mAdStirMediaId, mAdStirSpotId);
            yield return new WaitForSeconds(Mathf.Max(30.0f, mRefreshTime));
        }
        #else
        return null;
        #endif
    }
		public GooglePlay_InAppPurchasePlugin_Android(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod createdCallback)
		{
			this.createdCallback = createdCallback;
			try
			{
				testTrialMode = desc.TestTrialMode;
				InAppIDs = desc.Android_GooglePlay_InAppIDs;
				
				native = new AndroidJavaClass("com.reignstudios.reignnativegoogleplay.GooglePlay_InAppPurchaseNative");
				string skus = "", types = "";
				foreach (var app in desc.Android_GooglePlay_InAppIDs)
				{
					if (app != desc.Android_GooglePlay_InAppIDs[0])
					{
						skus += ":";
						types += ":";
					}
					
					skus += app.ID;
					types += app.Type == InAppPurchaseTypes.NonConsumable ? "NonConsumable" : "Consumable";
				}
				native.CallStatic("Init", desc.Android_GooglePlay_Base64Key, skus, types, desc.Testing, desc.ClearNativeCache);
			}
			catch (Exception e)
			{
				Debug.LogError(e.Message);
				if (createdCallback != null) createdCallback(false);
			}
		}
Example #17
0
		public static void Enable(bool enabled){
			AndroidJavaObject _plugin;
			using(var pluginClass = new AndroidJavaClass("com.zendesk.unity.ZDK_Plugin")){
				_plugin = pluginClass.CallStatic<AndroidJavaObject>("instance");
			}
			_plugin.Call("enableLogger", enabled);
		}
Example #18
0
		public static void Initialize() {
			SoomlaUtils.LogDebug (TAG, "SOOMLA/UNITY Initializing Highway");
#if UNITY_ANDROID && !UNITY_EDITOR
			AndroidJNI.PushLocalFrame(100);
			using(AndroidJavaClass jniGrowHighwayClass = new AndroidJavaClass("com.soomla.highway.GrowHighway")) {

				AndroidJavaObject jniGrowHighwayInstance = jniGrowHighwayClass.CallStatic<AndroidJavaObject>("getInstance");
				jniGrowHighwayInstance.Call("initialize", HighwaySettings.HighwayGameKey, HighwaySettings.HighwayEnvKey);

				// Uncomment this and change the URL for testing
//				using(AndroidJavaClass jniConfigClass = new AndroidJavaClass("com.soomla.highway.HighwayConfig")) {
//					AndroidJavaObject jniConfigObject = jniConfigClass.CallStatic<AndroidJavaObject>("getInstance");
//					jniConfigObject.Call("setUrls", "http://example.com", "http://example.com");
//				}

				jniGrowHighwayInstance.Call("start");
			}
			AndroidJNI.PopLocalFrame(IntPtr.Zero);
#elif UNITY_IOS && !UNITY_EDITOR
			growHighway_initialize(HighwaySettings.HighwayGameKey, HighwaySettings.HighwayEnvKey);

			// Uncomment this and change the URL for testing
//			growHighway_setHighwayUrl("http://example.com");
//			growHighway_setServicesUrl("http://example.com");

			growHighway_start();
#else
			SoomlaUtils.LogError(TAG, "Highway only works on Android or iOS devices !");
		//	UnityEditor.EditorApplication.isPlaying = false;
#endif
		}
    void HideNavigationBar()
    {
        #if UNITY_ANDROID
        lock(this)
        {
            using(javaClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
            {
                unityActivity = javaClass.GetStatic<AndroidJavaObject>("currentActivity");
            }

            if(unityActivity == null)
            {
                return;
            }

            using(javaClass = new AndroidJavaClass("com.rak24.androidimmersivemode.Main"))
            {
                if(javaClass == null)
                {
                    return;
                }
                else
                {
                    javaObj = javaClass.CallStatic<AndroidJavaObject>("instance");
                    if(javaObj == null)
                        return;
                    unityActivity.Call("runOnUiThread",new AndroidJavaRunnable(() =>
                                                                               {
                        javaObj.Call("EnableImmersiveMode", unityActivity);
                    }));
                }
            }
        }
        #endif
    }
		public Amazon_InAppPurchasePlugin_Android(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod createdCallback)
		{
			this.createdCallback = createdCallback;
			try
			{
				testTrialMode = desc.TestTrialMode;
				InAppIDs = desc.Android_Amazon_InAppIDs;
				
				native = new AndroidJavaClass("com.reignstudios.reignnativeamazon.Amazon_InAppPurchaseNative");
				string skus = "", types = "";
				foreach (var app in desc.Android_Amazon_InAppIDs)
				{
					if (app != desc.Android_Amazon_InAppIDs[0])
					{
						skus += ":";
						types += ":";
					}
					
					skus += app.ID;
					types += app.Type == InAppPurchaseTypes.NonConsumable ? "ENTITLED" : "CONSUMABLE";
				}
				native.CallStatic("Init", skus, types, desc.Testing);
			}
			catch (Exception e)
			{
				Debug.LogError(e.Message);
				if (createdCallback != null) createdCallback(false);
			}
		}
		protected override void _setFastestDurationMillis(Level level, long duration) {
			AndroidJNI.PushLocalFrame(100);
			using(AndroidJavaClass jniLevelStorage = new AndroidJavaClass("com.soomla.levelup.data.LevelStorage")) {
				jniLevelStorage.CallStatic("setFastestDurationMillis", level.ID, duration);
			}
			AndroidJNI.PopLocalFrame(IntPtr.Zero);
		}
        static OpenIAB_Android()
        {
            if (Application.platform != RuntimePlatform.Android)
            {
                STORE_GOOGLE = "STORE_GOOGLE";
                STORE_AMAZON = "STORE_AMAZON";
                STORE_SAMSUNG = "STORE_SAMSUNG";
                STORE_NOKIA = "STORE_NOKIA";
                STORE_YANDEX = "STORE_YANDEX";
                return;
            }

            AndroidJNI.AttachCurrentThread();

            // Find the plugin instance
            using (var pluginClass = new AndroidJavaClass("org.onepf.openiab.UnityPlugin"))
            {
                _plugin = pluginClass.CallStatic<AndroidJavaObject>("instance");
                STORE_GOOGLE = pluginClass.GetStatic<string>("STORE_GOOGLE");
                STORE_AMAZON = pluginClass.GetStatic<string>("STORE_AMAZON");
                STORE_SAMSUNG = pluginClass.GetStatic<string>("STORE_SAMSUNG");
                STORE_NOKIA = pluginClass.GetStatic<string>("STORE_NOKIA");
                STORE_YANDEX = pluginClass.GetStatic<string>("STORE_YANDEX");
            }
        }
Example #23
0
        public static void showAlertDialog(String parameters)
        {
            AndroidJNI.AttachCurrentThread();

                AndroidJavaClass uiClass = new AndroidJavaClass("com.gamedonia.utilities.GamedoniaUI");
                uiClass.CallStatic("showAlertDialog",new object [] {parameters});
        }
		public static void GetRanking(string gameObjectName,
		                              string callbackMethodName,
		                              string rankingId,
		                              RankingRange type,
		                              RankingCursorOrigin origin,
		                              int cursor,
		                              int limit){
			#if UNITY_ANDROID
			AndroidJavaClass nakamapClass = new AndroidJavaClass("com.kayac.lobi.sdk.ranking.unity.LobiRankingBridge");  
			nakamapClass.CallStatic("getRanking", gameObjectName, callbackMethodName, "id", rankingId, (int)type, (int)origin, cursor, limit);
			#endif
			
			#if ((UNITY_IOS || UNITY_IPHONE) && ! UNITY_EDITOR)
			byte[] cGameObjectName     = System.Text.Encoding.UTF8.GetBytes(gameObjectName);
			byte[] cCallbackMethodName = System.Text.Encoding.UTF8.GetBytes(callbackMethodName);
			byte[] cRankingId          = System.Text.Encoding.UTF8.GetBytes(rankingId);
			LobiRanking_get_ranking_(cGameObjectName, cGameObjectName.Length,
			                         cCallbackMethodName, cCallbackMethodName.Length,
			                         cRankingId, cRankingId.Length,
			                         (int)type,
			                         (int)origin,
			                         cursor,
			                         limit);
			#endif
		}
        public override void AddOSSpecificExternalDatasetSearchDirs()
        {
    #if UNITY_ANDROID
            if (Application.platform == RuntimePlatform.Android)
            {
                // Get the external storage directory
                AndroidJavaClass jclassEnvironment = new AndroidJavaClass("android.os.Environment");
                AndroidJavaObject jobjFile = jclassEnvironment.CallStatic<AndroidJavaObject>("getExternalStorageDirectory");
                string externalStorageDirectory = jobjFile.Call<string>("getAbsolutePath");

                // Get the package name
                AndroidJavaObject jobjActivity = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic<AndroidJavaObject>("currentActivity");
                string packageName = jobjActivity.Call<string>("getPackageName");

                // Add some best practice search directories
                //
                // Assumes just Vufroria datasets extracted to the files directory
                AddExternalDatasetSearchDir(externalStorageDirectory + "/Android/data/" + packageName + "/files/");

                // Assume entire StreamingAssets dir is extracted here and our datasets are in the "Vuforia/DeviceDatabases" directory
                AddExternalDatasetSearchDir(externalStorageDirectory + "/Android/data/" + packageName + "/files/Vuforia/DeviceDatabases/");

                // Assume entire StreamingAssets dir is extracted here and our datasets are in the "QCAR" directory
                AddExternalDatasetSearchDir(externalStorageDirectory + "/Android/data/" + packageName + "/files/QCAR/");
            }
#endif //UNITY_ANDROID
        }
Example #26
0
	// Use this for initialization
	public void OnclickButton()
    {
        using (AndroidJavaClass jc = new AndroidJavaClass("com.example.yoon.newgps.BridgeActivity"))
        {
            jc.CallStatic("SetToast", "hello world");
        }
    }
Example #27
0
    public static void Unzip(string zipFilePath, string location)
    {
        Debug.Log ("Entrando en unzip");
        #if UNITY_ANDROID
        using (AndroidJavaClass zipper = new AndroidJavaClass ("com.tsw.zipper")) {
            zipper.CallStatic ("unzip", zipFilePath, location);
        }
        #elif UNITY_IPHONE
        unzip (zipFilePath, location);
        #else
        Debug.Log ("UNZIP WINDOWS");
        Directory.CreateDirectory (location);

        Debug.Log ("DIRECTORIO CREADO");

        using (ZipFile zip = ZipFile.Read (zipFilePath)) {
            //current = zip;
            zip.ExtractAll (location, ExtractExistingFileAction.OverwriteSilently);
        }

        Debug.Log ("TERMINADO");

        /*int n;
        using(ZipFile zip = ZipFile.Read(zipFilePath))
        {
            zip.ExtractProgress += zip_ExtractProgress;
            n = 0;
            foreach (ZipEntry entry in zip)
            {
                n++;
                entry.Extract(location, ExtractExistingFileAction.OverwriteSilently);
                }
        }*/
        #endif
    }
Example #28
0
		public static void Initialize() {
			if (Instance == null) {
				Instance = GetSynchronousCodeGeneratedInstance<CoreEvents>();
				SoomlaUtils.LogDebug(TAG, "Initializing CoreEvents and Soomla Core ...");
#if UNITY_ANDROID && !UNITY_EDITOR
				AndroidJNI.PushLocalFrame(100);
				
				using(AndroidJavaClass jniStoreConfigClass = new AndroidJavaClass("com.soomla.SoomlaConfig")) {
					jniStoreConfigClass.SetStatic("logDebug", CoreSettings.DebugMessages);
				}
				
				// Initializing SoomlaEventHandler
				using(AndroidJavaClass jniEventHandler = new AndroidJavaClass("com.soomla.core.unity.SoomlaEventHandler")) {
					jniEventHandler.CallStatic("initialize");
				}
				
				// Initializing Soomla Secret
				using(AndroidJavaClass jniSoomlaClass = new AndroidJavaClass("com.soomla.Soomla")) {
					AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); 
					AndroidJavaObject currentActivity = jc.GetStatic<AndroidJavaObject>("currentActivity");
					jniSoomlaClass.CallStatic("initialize", currentActivity, CoreSettings.SoomlaSecret);
				}
				AndroidJNI.PopLocalFrame(IntPtr.Zero);
#elif UNITY_IOS && !UNITY_EDITOR
				soomlaCore_Init(CoreSettings.SoomlaSecret, CoreSettings.DebugMessages);
#elif UNITY_WP8 && !UNITY_EDITOR
				SoomlaWpCore.SoomlaConfig.logDebug = CoreSettings.DebugMessages;
				SoomlaWpCore.Soomla.initialize(CoreSettings.SoomlaSecret);
				BusProvider.Instance.Register(CoreEvents.instance);
#endif
			}
        }
    public static void Zip(string zipFileName, params string[] files)
    {
        #if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX
        string path = Path.GetDirectoryName(zipFileName);
        Directory.CreateDirectory(path);

        using (ZipFile zip = new ZipFile())
        {
            foreach (string file in files)
            {
                zip.AddFile(file, "");
            }
            zip.Save(zipFileName);
        }
        #elif UNITY_ANDROID
        using (AndroidJavaClass zipper = new AndroidJavaClass ("com.tsw.zipper")) {
            {
                zipper.CallStatic ("zip", zipFileName, files);
            }
        }
        #elif UNITY_IPHONE
        foreach (string file in files) {
            addZipFile (file);
        }
        zip (zipFileName);
        #endif
    }
Example #30
0
		public static void Initialize() {
			SoomlaUtils.LogDebug(TAG, "Initializing CoreEvents and Soomla Core ...");
#if UNITY_ANDROID && !UNITY_EDITOR
			AndroidJNI.PushLocalFrame(100);

			using(AndroidJavaClass jniStoreConfigClass = new AndroidJavaClass("com.soomla.SoomlaConfig")) {
				jniStoreConfigClass.SetStatic("logDebug", CoreSettings.DebugMessages);
			}

			// Initializing SoomlaEventHandler
			using(AndroidJavaClass jniEventHandler = new AndroidJavaClass("com.soomla.core.unity.SoomlaEventHandler")) {
				jniEventHandler.CallStatic("initialize");
			}

			// Initializing Soomla Secret
			using(AndroidJavaClass jniSoomlaClass = new AndroidJavaClass("com.soomla.Soomla")) {
				jniSoomlaClass.CallStatic("initialize", CoreSettings.SoomlaSecret);
			}
			AndroidJNI.PopLocalFrame(IntPtr.Zero);
#elif UNITY_IOS && !UNITY_EDITOR
			soomlaCore_Init(CoreSettings.SoomlaSecret, CoreSettings.DebugMessages);
#elif UNITY_WP8 && !UNITY_EDITOR
            SoomlaWpCore.SoomlaConfig.logDebug = CoreSettings.DebugMessages;
            SoomlaWpCore.Soomla.initialize(CoreSettings.SoomlaSecret);
            BusProvider.Instance.Register(CoreEvents.instance);
#endif

        }
Example #31
0
 public static void NativeGetCppVersion()
 {
     #if !UNITY_EDITOR && UNITY_ANDROID
     AndroidJavaClass jc = new AndroidJavaClass("com.snow.plugin.NativeBridge");
     jc.CallStatic("NativeGetCppVersion");
     #endif
 }
Example #32
0
 /// <summary>
 /// 调用静态方法
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="result"></param>
 /// <param name="jclass"></param>
 /// <param name="name"></param>
 /// <param name="args"></param>
 /// <returns></returns>
 public static bool UPvr_CallStaticMethod <T>(ref T result, UnityEngine.AndroidJavaClass jclass, string name, params object[] args)
 {
     try
     {
         result = jclass.CallStatic <T>(name, args);
         return(true);
     }
     catch (AndroidJavaException e)
     {
         Debug.LogError("Exception calling static method " + name + ": " + e);
         return(false);
     }
 }
Example #33
0
    UnityEngine.AndroidJavaObject GetPluginInstance()
    {
        if (activityContext == null)
        {
            using (UnityEngine.AndroidJavaClass activityClass = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
                activityContext = activityClass.GetStatic <UnityEngine.AndroidJavaObject>("currentActivity");
            }
        }

        using (UnityEngine.AndroidJavaClass pluginClass = new UnityEngine.AndroidJavaClass(packageName + "." + className)) {
            if (unityMusicPluginInstance == null)
            {
                unityMusicPluginInstance = pluginClass.CallStatic <UnityEngine.AndroidJavaObject>("instance");
                unityMusicPluginInstance.Call("setContext", activityContext);
            }
        }

        return(unityMusicPluginInstance);
    }
Example #34
0
 public StreamPlugin_Android()
 {
     native = new UnityEngine.AndroidJavaClass("com.reignstudios.reignnative.StreamNative");
     native.CallStatic("Init");
 }
Example #35
0
    /// <summary>
    /// 连接安卓
    /// </summary>
    public void ConnectToAndriod()
    {
        try
        {
            UnityEngine.AndroidJavaClass unityPlayer = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer");
            activity            = unityPlayer.GetStatic <UnityEngine.AndroidJavaObject>("currentActivity");
            javaVrActivityClass = new UnityEngine.AndroidJavaClass("com.picovr.picovrlib.VrActivity");
            SetInitActivity(activity.GetRawObject(), javaVrActivityClass.GetRawClass());
            canConnecttoActivity       = true;
            CanConnecttoActivity       = canConnecttoActivity;
            PicoVRManager.SDK.inPicovr = true;
            Headweartype = (int)PicoVRManager.SDK.DeviceType;
            SetPupillaryPoint(PupillaryPoint);
            model = javaVrActivityClass.CallStatic <string>("getBuildModel");
            Debug.Log("model = " + model);
            if (model == "Pico Neo DK")
            {
                model = "Falcon";
            }
            Debug.Log("SDK Version = " + GetSDKVersion() + ",UnityVersion=" + UnityVersion);
            Async  = GetAsyncFlag();
            useHMD = GetSensorExternal();
            if (useHMD)
            {
                usePhoneSensor = false;
            }
            Debug.Log("ConnectToAndroid: useHMD = " + useHMD + ", usePhoneSensor = " + usePhoneSensor);

            if (model == "Falcon")
            {
                usePhoneSensor = false;
                useHMD         = true;
                isFalcon       = true;
                Debug.Log("ConnectToAndroid: useHMD = " + useHMD + ", usePhoneSensor = " + usePhoneSensor + ", isFalcon = " + isFalcon);
                Headweartype = (int)PicoVRConfigProfile.DeviceTypes.PicoNeo;
                Debug.Log("Falcon : " + Headweartype.ToString());
                CallStaticMethod(javaVrActivityClass, "initFalconDevice", activity);
            }
            else
            {
                int deviceType = 0;
                CallStaticMethod <int>(ref deviceType, javaVrActivityClass, "readDeviceTypeFromWing", activity);
                Debug.Log("wingDeviceType = " + deviceType);
                if (deviceType != 0)
                {
                    Headweartype = deviceType;
                }
            }
            double[] parameters = new double[5];
            CallStaticMethod(ref parameters, javaVrActivityClass, "getDPIParameters", activity);
            ModifyScreenParameters(model, (int)parameters[0], (int)parameters[1], parameters[2], parameters[3], parameters[4]);
            ChangeHeadwear(Headweartype);
            SetAsyncModel(Async);
            Debug.Log("Async:" + Async.ToString() + "  Headweartype: " + Headweartype.ToString());
            startLarkConnectService();
        }
        catch (AndroidJavaException e)
        {
            Debug.LogError("ConnectToAndriod------------------------catch" + e.Message);
        }
    }
Example #36
0
        public static object UnboxArray(AndroidJavaObject obj)
        {
            Array array;

            if (obj == null)
            {
                return(null);
            }
            AndroidJavaClass  class2 = new AndroidJavaClass("java/lang/reflect/Array");
            AndroidJavaObject obj3   = obj.Call <AndroidJavaObject>("getClass", new object[0]).Call <AndroidJavaObject>("getComponentType", new object[0]);
            string            str    = obj3.Call <string>("getName", new object[0]);

            object[] args = new object[] { obj };
            int      num  = class2.Call <int>("getLength", args);

            if (obj3.Call <bool>("IsPrimitive", new object[0]))
            {
                if ("I" != str)
                {
                    if ("Z" != str)
                    {
                        if ("B" != str)
                        {
                            if ("S" != str)
                            {
                                if ("J" != str)
                                {
                                    if ("F" != str)
                                    {
                                        if ("D" != str)
                                        {
                                            if ("C" != str)
                                            {
                                                throw new Exception("JNI; Unknown argument type '" + str + "'");
                                            }
                                            array = new char[num];
                                        }
                                        else
                                        {
                                            array = new double[num];
                                        }
                                    }
                                    else
                                    {
                                        array = new float[num];
                                    }
                                }
                                else
                                {
                                    array = new long[num];
                                }
                            }
                            else
                            {
                                array = new short[num];
                            }
                        }
                        else
                        {
                            array = new byte[num];
                        }
                    }
                    else
                    {
                        array = new bool[num];
                    }
                }
                else
                {
                    array = new int[num];
                }
            }
            else if ("java.lang.String" == str)
            {
                array = new string[num];
            }
            else if ("java.lang.Class" == str)
            {
                array = new AndroidJavaClass[num];
            }
            else
            {
                array = new AndroidJavaObject[num];
            }
            for (int i = 0; i < num; i++)
            {
                object[] objArray2 = new object[] { obj, i };
                array.SetValue(Unbox(class2.CallStatic <AndroidJavaObject>("get", objArray2)), i);
            }
            return(array);
        }
        public static object UnboxArray(AndroidJavaObject obj)
        {
            if (obj == null)
            {
                return(null);
            }
            AndroidJavaClass  androidJavaClass   = new AndroidJavaClass("java/lang/reflect/Array");
            AndroidJavaObject androidJavaObject  = obj.Call <AndroidJavaObject>("getClass", new object[0]);
            AndroidJavaObject androidJavaObject2 = androidJavaObject.Call <AndroidJavaObject>("getComponentType", new object[0]);
            string            text = androidJavaObject2.Call <string>("getName", new object[0]);
            int num = androidJavaClass.Call <int>("getLength", new object[]
            {
                obj
            });
            Array array;

            if (androidJavaObject2.Call <bool>("IsPrimitive", new object[0]))
            {
                if ("I" == text)
                {
                    array = new int[num];
                }
                else
                {
                    if ("Z" == text)
                    {
                        array = new bool[num];
                    }
                    else
                    {
                        if ("B" == text)
                        {
                            array = new byte[num];
                        }
                        else
                        {
                            if ("S" == text)
                            {
                                array = new short[num];
                            }
                            else
                            {
                                if ("L" == text)
                                {
                                    array = new long[num];
                                }
                                else
                                {
                                    if ("F" == text)
                                    {
                                        array = new float[num];
                                    }
                                    else
                                    {
                                        if ("D" == text)
                                        {
                                            array = new double[num];
                                        }
                                        else
                                        {
                                            if (!("C" == text))
                                            {
                                                throw new Exception("JNI; Unknown argument type '" + text + "'");
                                            }
                                            array = new char[num];
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                if ("java.lang.String" == text)
                {
                    array = new string[num];
                }
                else
                {
                    if ("java.lang.Class" == text)
                    {
                        array = new AndroidJavaClass[num];
                    }
                    else
                    {
                        array = new AndroidJavaObject[num];
                    }
                }
            }
            for (int i = 0; i < num; i++)
            {
                array.SetValue(_AndroidJNIHelper.Unbox(androidJavaClass.CallStatic <AndroidJavaObject>("get", new object[]
                {
                    obj,
                    i
                })), i);
            }
            return(array);
        }