Exemplo n.º 1
0
        /// <summary>
        /// Show an Android toast message.
        /// </summary>
        /// <param name="message">Message string to show in the toast.</param>
        public static void ShowToastMessage(string message)
        {
#if UNITY_ANDROID
            using (var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
            {
                var unityActivity = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");
                if (unityActivity != null)
                {
                    using (unityActivity)
                        using (var toastClass = new AndroidJavaClass("android.widget.Toast"))
                        {
                            var args = new AndroidJavaRunnable(() =>
                            {
                                var toastObject = toastClass.CallStatic <AndroidJavaObject>("makeText", unityActivity, message, 0);
                                if (toastObject != null)
                                {
                                    using (toastObject)
                                    {
                                        toastObject.Call("show");
                                    }
                                }
                            });

                            unityActivity.Call("runOnUiThread", args);
                        }
                }
            }
#endif
        }
Exemplo n.º 2
0
    public static void DisableNavUI()

    {
        if (Application.platform != RuntimePlatform.Android)
        {
            return;
        }

#if UNITY_ANDROID
        using (AndroidJavaClass unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))

        {
            activityInstance = unityPlayerClass.GetStatic <AndroidJavaObject>("currentActivity");

            windowInstance = activityInstance.Call <AndroidJavaObject>("getWindow");

            viewInstance = windowInstance.Call <AndroidJavaObject>("getDecorView");

            AndroidJavaRunnable RunThis;

            RunThis = new AndroidJavaRunnable(new RunPtr(Run));

            activityInstance.Call("runOnUiThread", RunThis);
        }
#endif
    }
        private void runOnUiThread(AndroidJavaRunnable runnable)
        {
            //IL_0005: Unknown result type (might be due to invalid IL or missing references)
            //IL_000a: Expected O, but got Unknown
            AndroidJavaClass val = new AndroidJavaClass("com.unity3d.player.UnityPlayer");

            try
            {
                AndroidJavaObject @static = val.GetStatic <AndroidJavaObject>("currentActivity");
                try
                {
                    @static.Call("runOnUiThread", new object[1]
                    {
                        runnable
                    });
                }
                finally
                {
                    ((IDisposable)@static)?.Dispose();
                }
            }
            finally
            {
                ((IDisposable)val)?.Dispose();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Show the reward video Ad.
        /// </summary>
        public void ShowRewardVideoAd()
        {
            var activity = SDK.GetActivity();
            var runnable = new AndroidJavaRunnable(
                () => this.ad.Call("showRewardVideoAd", activity));

            activity.Call("runOnUiThread", runnable);
        }
Exemplo n.º 5
0
 void Awake()
 {
             #if (UNITY_ANDROID && !UNITY_EDITOR)
     AndroidJavaRunnable onInitCompleteRunnable = new AndroidJavaRunnable(CallInitComplete);
     NeumobAndroid.Initialize(ClientKey, onInitCompleteRunnable);
     Destroy(this);
             #endif
 }
Exemplo n.º 6
0
    protected void AssignEvent(string setter, Action listener)
    {
        AndroidJavaRunnable callback = delegate() {
            if (listener != null)
            {
                listener();
            }
        };

        milkyFoxRewardedVideo.Call(setter, callback);
    }
    protected void AssignEvent(string setter, Action listener)
    {
        AndroidJavaRunnable callback = delegate() {
            if (listener != null)
            {
                listener();
            }
        };

        milkyFoxInterstitialStaticAdapter.Call(setter, callback);
    }
Exemplo n.º 8
0
 /// Use initialize in order to setup the Neumob library. After successful initialization,
 // your network calls will automatically use Neumob's cloud and optimizations!
 public static void Initialize(string clientKey, AndroidJavaRunnable runnable)
 {
             #if (UNITY_ANDROID && !UNITY_EDITOR)
     if (mNeumobPlugin == null)
     {
         mNeumobPlugin = new AndroidJavaClass(NEUMOB_API_CLASS);
     }
     using (var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
         using (var currentActivity = unityPlayer.GetStatic <AndroidJavaObject> ("currentActivity")) {
             mNeumobPlugin.CallStatic("initialize", currentActivity, clientKey, runnable);
         }
     }
             #endif
 }
Exemplo n.º 9
0
    private static void DisableNavUI()
    {
        try
        {
            using (AndroidJavaClass unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
            {
                AndroidJavaObject activityInstance = unityPlayerClass.GetStatic <AndroidJavaObject>("currentActivity");
                AndroidJavaObject windowInstance   = activityInstance.Call <AndroidJavaObject>("getWindow");
                viewInstance = windowInstance.Call <AndroidJavaObject>("getDecorView");

                AndroidJavaRunnable runner = new AndroidJavaRunnable(Run);
                activityInstance.Call("runOnUiThread", runner);
            }
        }
        catch {}
    }
Exemplo n.º 10
0
	public static void DisableNavUI()
	{
		if (Application.platform != RuntimePlatform.Android)
			return;
		#if UNITY_ANDROID
		using (AndroidJavaClass unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
		{
			activityInstance = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity");
			windowInstance = activityInstance.Call<AndroidJavaObject>("getWindow");
			viewInstance = windowInstance.Call<AndroidJavaObject>("getDecorView");
			
			AndroidJavaRunnable RunThis;
			RunThis = new AndroidJavaRunnable(new RunPtr(Run));
			activityInstance.Call("runOnUiThread", RunThis);
		}
		#endif
	}
Exemplo n.º 11
0
 /// <summary>
 /// UI线程中运行
 /// </summary>
 /// <param name="r"></param>
 public static void RunOnUIThread(AndroidJavaRunnable r)
 {
     UnityActivity.Call("runOnUiThread", r);
 }
Exemplo n.º 12
0
 // UI线程中运行
 public static void AndroidRunOnUIThread(AndroidJavaRunnable r)
 {
     AndroidMainActivity().Call("runOnUiThread", r);
 }
Exemplo n.º 13
0
 public AndroidJavaRunnableProxy(AndroidJavaRunnable runnable)
     : base("java/lang/Runnable")
 {
     mRunnable = runnable;
 }
Exemplo n.º 14
0
 public static void RunOnUIThread(AndroidJavaRunnable runnable)
 {
     getContext().Call("runOnUiThread", runnable);
 }
Exemplo n.º 15
0
 public static void RunOnUiThread(AndroidJavaRunnable a)
 {
     GetActivity().Call("runOnUiThread", new AndroidJavaRunnable(a));
 }
Exemplo n.º 16
0
		public static IntPtr CreateJavaRunnable(AndroidJavaRunnable runnable){}
Exemplo n.º 17
0
 public AndroidJavaRunnableProxy(AndroidJavaRunnable runnable) : base("java/lang/Runnable")
 {
     this.mRunnable = runnable;
 }
Exemplo n.º 18
0
 private void RunOnUIThread(AndroidJavaRunnable runnable)
 {
     CurrentActivity.Call("runOnUiThread", new AndroidJavaRunnable(runnable));
 }
Exemplo n.º 19
0
 private void RunOnUIThread(AndroidJavaRunnable runnable)
 {
     CurrentActivity.Call("runOnUiThread", new AndroidJavaRunnable(runnable));
 }
Exemplo n.º 20
0
 // UI线程中运行
 public static void RunOnUIThread(AndroidJavaObject activityObj, AndroidJavaRunnable r)
 {
     activityObj.Call("runOnUiThread", r);
 }
Exemplo n.º 21
0
 public static void RunOnUiThread(AndroidJavaRunnable runnable)
 {
     GetActivityContext().Call("runOnUiThread", new AndroidJavaRunnable(runnable));
 }