Inheritance: AndroidJavaObject, IDisposable
Exemplo n.º 1
2
        public static void Init()
        {
            AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            if (jc == null)
            return;

            AndroidJavaObject joactivety = jc.GetStatic<AndroidJavaObject>("currentActivity");
            if (joactivety == null)
            return;
            AndroidJavaObject context = joactivety.Call<AndroidJavaObject>("getApplicationContext");
            // 初始化HttpDns
            AndroidJavaObject joDnsClass = new AndroidJavaObject("com.tencent.msdk.dns.MSDKDnsResolver");
            Debug.Log(" WGGetHostByName ===========" + joDnsClass);
            if (joDnsClass == null)
            return;
            m_dnsJo = joDnsClass.CallStatic<AndroidJavaObject>("getInstance");
            Debug.Log(" WGGetHostByName ===========" + m_dnsJo);
            if (m_dnsJo == null)
            return;
            m_dnsJo.Call("init", context);
            // 初始化灯塔
            AndroidJavaObject joBeaconClass = new AndroidJavaObject("com.tencent.beacon.event.UserAction");
            if (joBeaconClass == null)
            return;
            m_dnsJo.Call("initUserAction", context);
        }
Exemplo n.º 2
0
    void OnPostRender()
    {
        //DrawVignetteLine();
        screenFade();

        // if not find Overlay then Open eyebuffer only
        if (Pvr_UnitySDKEyeOverlay.Instances.Count <= 0)
        {
            int eyeTextureId = Pvr_UnitySDKManager.SDK.eyeTextureIds[IDIndex];
            Pvr_UnitySDKPluginEvent.IssueWithData(eventType, eyeTextureId);
        }

#if !UNITY_EDITOR && UNITY_ANDROID
        if (eyeSide == Eye.LeftEye && !setLevel && Pvr_UnitySDKManager.SDK.IsViewerLogicFlow)
        {
            AndroidJavaClass AvrAPI = new UnityEngine.AndroidJavaClass("com.unity3d.player.AvrAPI");
            Pvr_UnitySDKAPI.System.UPvr_CallStaticMethod(AvrAPI, "setVrThread");
            setLevel = true;
            Debug.Log("Viewer setVrThread");
        }
        else
        {
            return;
        }
#endif
    }
Exemplo n.º 3
0
    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
    }
    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
    }
Exemplo n.º 5
0
	// Use this for initialization
	public void OnclickButton()
    {
        using (AndroidJavaClass jc = new AndroidJavaClass("com.example.yoon.newgps.BridgeActivity"))
        {
            jc.CallStatic("SetToast", "hello world");
        }
    }
        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
        }
Exemplo n.º 7
0
	void Awake () {
		AndroidJavaClass ajc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
		this.androidJavaObject = ajc.GetStatic<AndroidJavaObject>("currentActivity");
        is_called_startFlag = false;
        recieve_from_Gear_MSG = "";		
		manager.is_gameOver = false;
	}
Exemplo n.º 8
0
        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");
            }
        }
Exemplo n.º 9
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
			}
        }
Exemplo n.º 10
0
    public void Init()
    {
#if UNITY_ANDROID
        jc = new AndroidJavaClass("unityplugin.phuongnd.com.androidplugin.MainActivity");
        Debug.Log("JavaClass -----------------> " + jc);
#endif
    }
Exemplo n.º 11
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;
			}
        public static bool UPvr_InitBatteryVolClass()
        {
#if ANDROID_DEVICE
            try
            {
                javaSysActivityClass = new UnityEngine.AndroidJavaClass("com.psmart.aosoperation.SysActivity");
                if (javaSysActivityClass != null && Pvr_UnitySDKManager.pvr_UnitySDKRender.activity != null)
                {
                    batteryjavaVrActivityClass = new UnityEngine.AndroidJavaClass("com.psmart.aosoperation.BatteryReceiver");
                    volumejavaVrActivityClass  = new AndroidJavaClass("com.psmart.aosoperation.AudioReceiver");

                    Pvr_UnitySDKAPI.System.UPvr_CallStaticMethod(javaSysActivityClass, "Pvr_InitAudioDevice", Pvr_UnitySDKManager.pvr_UnitySDKRender.activity);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                PLOG.E("startReceiver Error :" + e.ToString());
                return(false);
            }
#endif
            return(true);
        }
        public static bool UPvr_InitBatteryClass()
        {
#if ANDROID_DEVICE
            try
            {
                if (javaSysActivityClass == null)
                {
                    javaSysActivityClass = new UnityEngine.AndroidJavaClass("com.psmart.aosoperation.SysActivity");
                }

                if (javaSysActivityClass != null && Pvr_UnitySDKManager.pvr_UnitySDKRender.activity != null)
                {
                    if (batteryjavaVrActivityClass == null)
                    {
                        batteryjavaVrActivityClass = new UnityEngine.AndroidJavaClass("com.psmart.aosoperation.BatteryReceiver");
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                PLOG.E("startReceiver Error :" + e.ToString());
                return(false);
            }
#endif
            return(true);
        }
Exemplo n.º 14
0
    public void shareText()
    {
        //execute the below lines if being run on a Android device
    #if UNITY_ANDROID
        body = "Faltan " + RolCountdownController.daysRemaining + " días, " + RolCountdownController.hoursRemaining + " horas y " + RolCountdownController.minutesRemaining + " minutos para las próxima roleada!";

        //Refernece of AndroidJavaClass class for intent
        AndroidJavaClass intentClass = new AndroidJavaClass ("android.content.Intent");
        //Refernece of AndroidJavaObject class for intent
        AndroidJavaObject intentObject = new AndroidJavaObject ("android.content.Intent");
        //call setAction method of the Intent object created
        intentObject.Call<AndroidJavaObject>("setAction", intentClass.GetStatic<string>("ACTION_SEND"));
        //set the type of sharing that is happening
        intentObject.Call<AndroidJavaObject>("setType", "text/plain");
        //add data to be passed to the other activity i.e., the data to be sent
        intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_SUBJECT"), subject);
        intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_TEXT"), body);
        //get the current activity
        AndroidJavaClass unity = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
        AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity");
        //start the activity by sending the intent data
        currentActivity.Call ("startActivity", intentObject);
    #endif

    }
Exemplo n.º 15
0
 public Chat(IntPtr chatPtr, AndroidJavaObject chatJavaObject)
 {
     innerChat = chatPtr;
     innerChatJavaObject = chatJavaObject;
     if(javaUnityApplicasaChat==null)
         javaUnityApplicasaChat = new AndroidJavaClass("com.applicasaunity.Unity.ApplicasaChat");
 }
Exemplo n.º 16
0
        public static Dictionary <string, string> GetArguments()
        {
            if (Application.isEditor)
            {
                return(new Dictionary <string, string>());
            }

            try
            {
                using (var unityPlayer = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer"))
                    using (var currentActivity = unityPlayer.GetStatic <UnityEngine.AndroidJavaObject>("currentActivity"))
                        using (var intent = currentActivity.Call <UnityEngine.AndroidJavaObject>("getIntent"))
                        {
                            var hasExtra = intent.Call <bool>("hasExtra", "arguments");
                            if (hasExtra)
                            {
                                using (var extras = intent.Call <UnityEngine.AndroidJavaObject>("getExtras"))
                                {
                                    var arguments = extras.Call <string>("getString", "arguments").Split(' ');
                                    return(CommandLineUtility.ParseCommandLineArgs(arguments));
                                }
                            }
                        }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            return(new Dictionary <string, string>());
        }
Exemplo n.º 17
0
 public Colors(IntPtr colorsPtr, AndroidJavaObject colorsJavaObject)
 {
     innerColors = colorsPtr;
     innerColorsJavaObject = colorsJavaObject;
     if(javaUnityApplicasaColors==null)
         javaUnityApplicasaColors = new AndroidJavaClass("com.applicasaunity.Unity.ApplicasaColors");
 }
Exemplo n.º 18
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

        }
Exemplo n.º 19
0
 public static void NativeGetCppVersion()
 {
     #if !UNITY_EDITOR && UNITY_ANDROID
     AndroidJavaClass jc = new AndroidJavaClass("com.snow.plugin.NativeBridge");
     jc.CallStatic("NativeGetCppVersion");
     #endif
 }
Exemplo n.º 20
0
		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);
		}
Exemplo n.º 21
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
		}
		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);
			}
		}
Exemplo n.º 23
0
    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;
    }
Exemplo n.º 24
0
 static Density()
 {
     Value = 1.0f;
     #if UNITY_ANDROID
     using (
         AndroidJavaClass unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"),
         metricsClass = new AndroidJavaClass("android.util.DisplayMetrics")
         ) {
         using (
             AndroidJavaObject metricsInstance = new AndroidJavaObject("android.util.DisplayMetrics"),
             activityInstance = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity"),
             windowManagerInstance = activityInstance.Call<AndroidJavaObject>("getWindowManager"),
             displayInstance = windowManagerInstance.Call<AndroidJavaObject>("getDefaultDisplay")
             ) {
             displayInstance.Call ("getMetrics", metricsInstance);
             Value = metricsInstance.Get<float> ("density");
         }
     }
     #endif
     #if UNITY_IPHONE
     if (Application.platform != RuntimePlatform.OSXEditor) {
         Value = IOSDensity_ ();
     }
     #endif
 }
Exemplo n.º 25
0
	public static void CallStatic(string className, string methodName, params object[] args) {
		#if UNITY_ANDROID
		
		
		
		if(Application.platform != RuntimePlatform.Android) {
			return;
		}
		Debug.Log("AN: Using proxy for class: " + className + " method:" + methodName);
		
		try {
			
			AndroidJavaObject bridge;
			if(pool.ContainsKey(className)) {
				bridge = pool[className];
			} else {
				bridge = new AndroidJavaObject(className);
				pool.Add(className, bridge);
				
			}
			
			AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); 
			AndroidJavaObject act = jc.GetStatic<AndroidJavaObject>("currentActivity"); 
			
			act.Call("runOnUiThread", new AndroidJavaRunnable(() => { bridge.CallStatic(methodName, args); }));
			
			
		} catch(System.Exception ex) {
			Debug.LogWarning(ex.Message);
		}
		#endif
	}
Exemplo n.º 26
0
    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
    }
Exemplo n.º 27
0
		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 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
		}
Exemplo n.º 29
0
    void OnPostRender()
    {
        //DrawVignetteLine();
        screenFade();
        int eyeTextureId = Pvr_UnitySDKManager.SDK.eyeTextureIds[IDIndex];

        // SaveImage(Pvr_UnitySDKManager.SDK.eyeTextures[IDIndex], eye.ToString());
        Pvr_UnitySDKPluginEvent.IssueWithData(eventType, eyeTextureId);
        if (Input.GetKeyDown(KeyCode.JoystickButton0))
        {
            cube.transform.Rotate(0, 0, 360 * Time.deltaTime);
            SaveImages.SaveImage(Pvr_UnitySDKManager.SDK.eyeTextures[Pvr_UnitySDKManager.SDK.currEyeTextureIdx + (int)eye * 3], eye.ToString());
        }
#if !UNITY_EDITOR && UNITY_ANDROID
        if (eye == Eye.LeftEye && !setLevel && Pvr_UnitySDKManager.SDK.IsViewerLogicFlow)
        {
            AndroidJavaClass AvrAPI = new UnityEngine.AndroidJavaClass("com.unity3d.player.AvrAPI");
            Pvr_UnitySDKAPI.System.UPvr_CallStaticMethod(AvrAPI, "setVrThread");
            setLevel = true;
            Debug.Log("Viewer setVrThread");
        }
        else
        {
            return;
        }
#endif
    }
Exemplo n.º 30
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);
		}
Exemplo n.º 31
0
 public GameV(IntPtr gameVPtr, AndroidJavaObject gameVJavaObject)
 {
     innerGameV = gameVPtr;
     innerGameVJavaObject = gameVJavaObject;
     if(javaUnityApplicasaGameV==null)
         javaUnityApplicasaGameV = new AndroidJavaClass("com.applicasaunity.Unity.ApplicasaGameV");
 }
Exemplo n.º 32
0
 public DataManager(IntPtr dataManagerPtr, AndroidJavaObject dataManagerJavaObject)
 {
     innerDataManager = dataManagerPtr;
     innerDataManagerJavaObject = dataManagerJavaObject;
     if(javaUnityApplicasaDataManager==null)
         javaUnityApplicasaDataManager = new AndroidJavaClass("com.applicasaunity.Unity.ApplicasaDataManager");
 }
Exemplo n.º 33
0
        public void start(AdjustConfig adjustConfig)
        {
            AndroidJavaObject ajoEnvironment = adjustConfig.environment == AdjustEnvironment.Sandbox ?
                new AndroidJavaClass ("com.adjust.sdk.AdjustConfig").GetStatic<AndroidJavaObject> ("ENVIRONMENT_SANDBOX") :
                    new AndroidJavaClass ("com.adjust.sdk.AdjustConfig").GetStatic<AndroidJavaObject> ("ENVIRONMENT_PRODUCTION");

            AndroidJavaObject ajoAdjustConfig = new AndroidJavaObject ("com.adjust.sdk.AdjustConfig", ajoCurrentActivity, adjustConfig.appToken, ajoEnvironment);

            if (adjustConfig.logLevel != null) {
                AndroidJavaObject ajoLogLevel = new AndroidJavaClass ("com.adjust.sdk.LogLevel").GetStatic<AndroidJavaObject> (adjustConfig.logLevel.ToString().ToUpper());

                if (ajoLogLevel != null) {
                    ajoAdjustConfig.Call ("setLogLevel", ajoLogLevel);
                }
            }

            if (adjustConfig.attributionChangedDelegate != null) {
                onAttributionChangedListener = new AttributionChangeListener (adjustConfig.attributionChangedDelegate);
                ajoAdjustConfig.Call ("setOnAttributionChangedListener", onAttributionChangedListener);
            }

            ajoAdjustConfig.Call ("setSdkPrefix", adjustConfig.sdkPrefix);

            ajcAdjust.CallStatic ("onCreate", ajoAdjustConfig);
        }
Exemplo n.º 34
0
    void OnPostRender()
    {
        //DrawVignetteLine();
        screenFade();

        // eyebuffer
        int eyeTextureId = Pvr_UnitySDKManager.SDK.eyeTextureIds[IDIndex];

        Pvr_UnitySDKPluginEvent.IssueWithData(eventType, eyeTextureId);
        // boundary
        if (!Pvr_UnitySDKManager.SDK.HmdOnlyrot)
        {
            Pvr_UnitySDKPluginEvent.IssueWithData(boundaryEventType, Pvr_UnitySDKManager.SDK.RenderviewNumber);
        }

#if !UNITY_EDITOR && UNITY_ANDROID
        Pvr_UnitySDKPluginEvent.Issue(RenderEventType.EndEye);
        if (eyeSide == Eye.LeftEye && !setLevel && Pvr_UnitySDKManager.SDK.IsViewerLogicFlow)
        {
            AndroidJavaClass AvrAPI = new UnityEngine.AndroidJavaClass("com.unity3d.player.AvrAPI");
            Pvr_UnitySDKAPI.System.UPvr_CallStaticMethod(AvrAPI, "setVrThread");
            setLevel = true;
            Debug.Log("Viewer setVrThread");
        }
        else
        {
            return;
        }
#endif
    }
Exemplo n.º 35
0
        public static void showAlertDialog(String parameters)
        {
            AndroidJNI.AttachCurrentThread();

                AndroidJavaClass uiClass = new AndroidJavaClass("com.gamedonia.utilities.GamedoniaUI");
                uiClass.CallStatic("showAlertDialog",new object [] {parameters});
        }
Exemplo n.º 36
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
    }
Exemplo n.º 37
0
 public void Dispose()
 {
     if (native != null)
     {
         native.Dispose();
         native = null;
     }
 }
Exemplo n.º 38
0
    public static string GetAndroidAdMobID()
    {
        UnityEngine.AndroidJavaClass  up = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer");
        UnityEngine.AndroidJavaObject currentActivity = up.GetStatic <UnityEngine.AndroidJavaObject>("currentActivity");
        UnityEngine.AndroidJavaObject contentResolver = currentActivity.Call <UnityEngine.AndroidJavaObject>("getContentResolver");
        UnityEngine.AndroidJavaObject secure          = new UnityEngine.AndroidJavaObject("android.provider.Settings$Secure");
        string deviceID = secure.CallStatic <string>("getString", contentResolver, "android_id");

        return(Md5Sum(deviceID).ToUpper());
    }
    private void Awake()
    {
        if (instance != null)
        {
            Destroy(this);
            return;
        }

        if (!CriAtomPlugin.IsLibraryInitialized())
        {
            Debug.LogError("[CRIWARE] Atom library is not initialized. Cannot setup CriAtomExOutputDeviceObserver.");
            Destroy(this);
            return;
        }

        instance = this;

#if CRIWAREPLUGIN_SUPPORT_OUTPUTDEVICE_OBSERVER
#if !UNITY_EDITOR && UNITY_IOS
        bool isStarted = UnsafeNativeMethods.criAtomUnity_StartOutputDeviceObserver_IOS();
        if (!isStarted)
        {
            Debug.LogError("[CRIWARE] CriAtomOutputDeviceObserver cannot start while Atom library is not initialized.");
        }
#elif !UNITY_EDITOR && UNITY_ANDROID
        UnityEngine.AndroidJavaClass  jc       = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer");
        UnityEngine.AndroidJavaObject activity = jc.GetStatic <UnityEngine.AndroidJavaObject>("currentActivity");

        if (checker == null)
        {
            checker = new UnityEngine.AndroidJavaObject("com.crimw.crijavaclasses.CriOutputDeviceObserver", activity, this.gameObject.name, "CallbackFromObserver_ANDROID");
        }
        if (checker == null)
        {
            Debug.LogError("[CRIWARE] Cannot load CriOutputDeviceObserver class in library.");
        }
        checker.Call("Start", activity);
        CheckOutputDevice_ANDROID();
#endif
        isConnected = lastIsConnected = IsDeviceConnected;
        deviceType  = lastDeviceType = DeviceType;
        if (_onDeviceConnectionChanged != null)
        {
            _onDeviceConnectionChanged(isConnected, deviceType);
        }
#elif !UNITY_EDITOR
        Debug.Log("[CRIWARE] CriAtomOutputDeviceObserver is not supported on this platform.");
#endif
        if (this.dontDestroyOnLoad)
        {
            GameObject.DontDestroyOnLoad(this.gameObject);
        }
    }
Exemplo n.º 40
0
    /************************************   Public Interfaces **********************************/
    #region       PublicInterfaces

    public void ConnectToAndriod()
    {
#if ANDROID_DEVICE
        try
        {
            Debug.Log("PvrLog SDK Version :  " + Pvr_UnitySDKAPI.System.UPvr_GetSDKVersion().ToString() + "  Unity Script Version :" + Pvr_UnitySDKAPI.System.UPvr_GetUnitySDKVersion().ToString());
            UnityEngine.AndroidJavaClass unityPlayer = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer");
            activity                   = unityPlayer.GetStatic <UnityEngine.AndroidJavaObject>("currentActivity");
            javaVrActivityClass        = new UnityEngine.AndroidJavaClass("com.psmart.vrlib.VrActivity");
            javaserviceClass           = new AndroidJavaClass("com.picovr.picovrlib.hummingbirdclient.UnityClient");
            javaVrActivityLongReceiver = new UnityEngine.AndroidJavaClass("com.psmart.vrlib.HomeKeyReceiver");
            javaSysActivityClass       = new UnityEngine.AndroidJavaClass("com.psmart.aosoperation.SysActivity");
            javaVrActivityClientClass  = new UnityEngine.AndroidJavaClass("com.psmart.vrlib.PvrClient");
            Pvr_UnitySDKAPI.System.Pvr_SetInitActivity(activity.GetRawObject(), javaVrActivityClass.GetRawClass());
            model = javaVrActivityClass.CallStatic <string>("Pvr_GetBuildModel");

            double[] parameters = new double[5];
            Pvr_UnitySDKAPI.System.UPvr_CallStaticMethod(ref parameters, javaVrActivityClass, "getDPIParameters", activity);
            int platformType = -1;
            int enumindex    = (int)Pvr_UnitySDKAPI.GlobalIntConfigs.PLATFORM_TYPE;
            Pvr_UnitySDKAPI.Render.UPvr_GetIntConfig(enumindex, ref platformType);

            string systemfps = "";
            Pvr_UnitySDKAPI.System.UPvr_CallStaticMethod <string>(ref systemfps, javaserviceClass, "getSysproc", "persist.pvr.debug.appfps");
            if (systemfps != "")
            {
                Pvr_UnitySDKManager.SDK.systemFPS = Convert.ToBoolean(Convert.ToInt16(systemfps));
            }

            if (platformType == 0)
            {
                Pvr_UnitySDKAPI.Render.UPvr_ChangeScreenParameters(model, (int)parameters[0], (int)parameters[1], parameters[2], parameters[3], parameters[4]);
                Screen.sleepTimeout = SleepTimeout.NeverSleep;
            }
            if (Pvr_UnitySDKAPI.System.UPvr_IsPicoActivity())
            {
                bool setMonoPresentation = Pvr_UnitySDKAPI.System.UPvr_SetMonoPresentation();
                Debug.Log("ConnectToAndriod set monoPresentation success ?-------------" + setMonoPresentation.ToString());

                bool isPresentationExisted = Pvr_UnitySDKAPI.System.UPvr_IsPresentationExisted();
                Debug.Log("ConnectToAndriod presentation existed ?-------------" + isPresentationExisted.ToString());
            }
            isShellMode = GetIsShellMode();
            Debug.Log("ConnectToAndriod isShellMode ?-------------" + isShellMode.ToString());
        }
        catch (AndroidJavaException e)
        {
            PLOG.E("ConnectToAndriod--catch" + e.Message);
        }
#endif
        canConnecttoActivity = true;
    }
Exemplo n.º 41
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);
     }
 }
Exemplo n.º 42
0
    public void ConnectToAndriod()
    {
#if ANDROID_DEVICE
        try
        {
            Debug.Log("SDK Version :  " + Pvr_UnitySDKAPI.System.UPvr_GetSDKVersion().ToString() + "  Unity Script Version :" + Pvr_UnitySDKAPI.System.UPvr_GetUnitySDKVersion().ToString());
            UnityEngine.AndroidJavaClass unityPlayer = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer");
            activity                   = unityPlayer.GetStatic <UnityEngine.AndroidJavaObject>("currentActivity");
            javaVrActivityClass        = new UnityEngine.AndroidJavaClass("com.psmart.vrlib.VrActivity");
            javaserviceClass           = new AndroidJavaClass("com.picovr.picovrlib.hummingbirdclient.UnityClient");
            javaVrActivityLongReceiver = new UnityEngine.AndroidJavaClass("com.psmart.vrlib.HomeKeyReceiver");
            javaSysActivityClass       = new UnityEngine.AndroidJavaClass("com.psmart.aosoperation.SysActivity");
            javaVrActivityClientClass  = new UnityEngine.AndroidJavaClass("com.psmart.vrlib.PvrClient");
            Pvr_UnitySDKAPI.System.Pvr_SetInitActivity(activity.GetRawObject(), javaVrActivityClass.GetRawClass());
            model = javaVrActivityClass.CallStatic <string>("Pvr_GetBuildModel");

/*
 *          if (model == "Falcon")
 *          {
 *              Headweartype = (int)Pvr_UnitySDKConfigProfile.DeviceTypes.PicoNeo;
 *              Debug.Log("Falcon : " + Headweartype.ToString());
 *              Pvr_UnitySDKAPI.System.UPvr_CallStaticMethod(javaVrActivityClass, "initFalconDevice", activity);
 *          }
 */
            double[] parameters = new double[5];
            Pvr_UnitySDKAPI.System.UPvr_CallStaticMethod(ref parameters, javaVrActivityClass, "getDPIParameters", activity);
            int platformType = -1;
            int enumindex    = (int)Pvr_UnitySDKAPI.GlobalIntConfigs.PLATFORM_TYPE;
            Pvr_UnitySDKAPI.Render.UPvr_GetIntConfig(enumindex, ref platformType);

            string systemfps = "";
            Pvr_UnitySDKAPI.System.UPvr_CallStaticMethod <string>(ref systemfps, javaserviceClass, "getSysproc", "persist.pvr.debug.appfps");
            if (systemfps != "")
            {
                Pvr_UnitySDKManager.SDK.systemFPS = Convert.ToBoolean(Convert.ToInt16(systemfps));
            }

            if (platformType == 0)
            {
                Pvr_UnitySDKAPI.Render.UPvr_ChangeScreenParameters(model, (int)parameters[0], (int)parameters[1], parameters[2], parameters[3], parameters[4]);
                Screen.sleepTimeout = SleepTimeout.NeverSleep;
            }
            //Pvr_UnitySDKAPI.Render.UPvr_ChangeHeadwear(Headweartype);
        }
        catch (AndroidJavaException e)
        {
            Debug.LogError("ConnectToAndriod------------------------catch" + e.Message);
        }
#endif
        canConnecttoActivity = true;
    }
    private void CheckOutputDevice_ANDROID()
    {
        if (checker == null)
        {
            return;
        }

        UnityEngine.AndroidJavaClass  jc       = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer");
        UnityEngine.AndroidJavaObject activity = jc.GetStatic <UnityEngine.AndroidJavaObject>("currentActivity");
        int device = checker.Call <int>("CheckOutputDeviceType", activity);

        deviceType  = (OutputDeviceType)device;
        isConnected = (deviceType != OutputDeviceType.BuiltinSpeaker);
    }
Exemplo n.º 44
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);
    }
    void OnPostRender()
    {
        //DrawVignetteLine();
        screenFade();
        int eyeTextureId = Pvr_UnitySDKManager.SDK.eyeTextureIds[IDIndex];

        // SaveImage(Pvr_UnitySDKManager.SDK.eyeTextures[IDIndex], eye.ToString());
        Pvr_UnitySDKPluginEvent.IssueWithData(eventType, eyeTextureId);
                #if !UNITY_EDITOR && UNITY_ANDROID
        if (eye == Eye.LeftEye && !setLevel && Pvr_UnitySDKManager.SDK.IsViewerLogicFlow)
        {
            AndroidJavaClass AvrAPI = new UnityEngine.AndroidJavaClass("com.unity3d.player.AvrAPI");
            Pvr_UnitySDKAPI.System.UPvr_CallStaticMethod(AvrAPI, "setVrThread");
            setLevel = true;
        }
        else
        {
            return;
        }
                #endif
    }
    private void OnDestroy()
    {
        if (instance != this)
        {
            return;
        }
        instance = null;

#if CRIWAREPLUGIN_SUPPORT_OUTPUTDEVICE_OBSERVER
#if !UNITY_EDITOR && UNITY_IOS
        UnsafeNativeMethods.criAtomUnity_StopOutputDeviceObserver_IOS();
#elif !UNITY_EDITOR && UNITY_ANDROID
        UnityEngine.AndroidJavaClass  jc       = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer");
        UnityEngine.AndroidJavaObject activity = jc.GetStatic <UnityEngine.AndroidJavaObject>("currentActivity");
        if (activity != null && checker != null)
        {
            checker.Call("Stop", activity);
        }
        checker = null;
#endif
#endif
    }
Exemplo n.º 47
0
    private bool InitViewerBatteryVolClass()
    {
#if !UNITY_EDITOR && UNITY_ANDROID
        try
        {
            if (pvr_UnitySDKRender.activity != null)
            {
                batteryjavaVrActivityClass = new UnityEngine.AndroidJavaClass("com.psmart.aosoperation.BatteryReceiver");
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (Exception e)
        {
            Debug.LogError("startReceiver Error :" + e.ToString());
            return(false);
        }
#endif
        return(true);
    }
Exemplo n.º 48
0
 /*****************************音量亮度*************************************/
 public override bool initBatteryVolClass()
 {
     try
     {
         if (javaVrActivityClass != null && activity != null)
         {
             batteryjavaVrActivityClass = new UnityEngine.AndroidJavaClass("com.picovr.picovrlib.BatteryReceiver");
             volumejavaVrActivityClass  = new AndroidJavaClass("com.picovr.picovrlib.AudioReceiver");
             CallStaticMethod(javaVrActivityClass, "initAudioDevice", activity);
             CallStaticMethod <AndroidJavaObject>(ref vrActivityObj, javaVrActivityClass, "InitVRActivity");
             Debug.Log("INIT");
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception e)
     {
         Debug.LogError("startReceiver Error :" + e.ToString());
         return(false);
     }
 }
Exemplo n.º 49
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);
        }
Exemplo n.º 50
0
 public StreamPlugin_Android()
 {
     native = new UnityEngine.AndroidJavaClass("com.reignstudios.reignnative.StreamNative");
     native.CallStatic("Init");
 }
Exemplo n.º 51
0
 /// <summary>
 /// <para></para>
 /// </summary>
 /// <param name="javaInterface">Java interface to be implemented by the proxy.</param>
 public AndroidJavaProxy(AndroidJavaClass javaInterface)
 {
     this.javaInterface = javaInterface;
 }
        public static object Unbox(AndroidJavaObject obj)
        {
            object result;

            if (obj == null)
            {
                result = null;
            }
            else
            {
                AndroidJavaObject androidJavaObject = obj.Call <AndroidJavaObject>("getClass", new object[0]);
                string            b = androidJavaObject.Call <string>("getName", new object[0]);
                if ("java.lang.Integer" == b)
                {
                    result = obj.Call <int>("intValue", new object[0]);
                }
                else if ("java.lang.Boolean" == b)
                {
                    result = obj.Call <bool>("booleanValue", new object[0]);
                }
                else if ("java.lang.Byte" == b)
                {
                    result = obj.Call <byte>("byteValue", new object[0]);
                }
                else if ("java.lang.Short" == b)
                {
                    result = obj.Call <short>("shortValue", new object[0]);
                }
                else if ("java.lang.Long" == b)
                {
                    result = obj.Call <long>("longValue", new object[0]);
                }
                else if ("java.lang.Float" == b)
                {
                    result = obj.Call <float>("floatValue", new object[0]);
                }
                else if ("java.lang.Double" == b)
                {
                    result = obj.Call <double>("doubleValue", new object[0]);
                }
                else if ("java.lang.Character" == b)
                {
                    result = obj.Call <char>("charValue", new object[0]);
                }
                else if ("java.lang.String" == b)
                {
                    result = obj.Call <string>("toString", new object[0]);
                }
                else if ("java.lang.Class" == b)
                {
                    result = new AndroidJavaClass(obj.GetRawObject());
                }
                else if (androidJavaObject.Call <bool>("isArray", new object[0]))
                {
                    result = _AndroidJNIHelper.UnboxArray(obj);
                }
                else
                {
                    result = obj;
                }
            }
            return(result);
        }
Exemplo n.º 53
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);
        }
    }
Exemplo n.º 54
0
        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 ("J" == 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);
        }