public static void StartNsd() { #if __UNITY_ANDROID__ UnityEngine.AndroidJavaClass c = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer"); var context = c.GetStatic <UnityEngine.AndroidJavaObject>("currentActivity"); var arg = new UnityEngine.AndroidJavaObject("java.lang.String", "servicediscovery"); context.Call <UnityEngine.AndroidJavaObject>("getSystemService", arg); context.Dispose(); arg.Dispose(); c.Dispose(); #endif }
static RegisterService() { Couchbase.Lite.Unity.UnityMainThreadScheduler.TaskFactory.StartNew(() => { UnityEngine.AndroidJavaClass c = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer"); var context = c.GetStatic <UnityEngine.AndroidJavaObject>("currentActivity"); if (context == null) { c.Dispose(); throw new Exception("Failed to get context"); } var arg = new UnityEngine.AndroidJavaObject("java.lang.String", "servicediscovery"); context.Call <UnityEngine.AndroidJavaObject>("getSystemService", arg); context.Dispose(); arg.Dispose(); c.Dispose(); _primedEvent.Set(); }); }
static RegisterService() { UnityEngine.AndroidJavaClass c = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer"); var context = c.GetStatic<UnityEngine.AndroidJavaObject>("currentActivity"); if (context == null) { c.Dispose(); throw new Exception("Failed to get context"); } var arg = new UnityEngine.AndroidJavaObject("java.lang.String", "servicediscovery"); context.Call<UnityEngine.AndroidJavaObject>("getSystemService", arg); context.Dispose(); arg.Dispose(); c.Dispose(); }
static ServiceBrowser() { Couchbase.Lite.Unity.UnityMainThreadScheduler.TaskFactory.StartNew(() => { UnityEngine.AndroidJavaClass c = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer"); var context = c.GetStatic<UnityEngine.AndroidJavaObject>("currentActivity"); if (context == null) { c.Dispose(); throw new Exception("Failed to get context"); } var arg = new UnityEngine.AndroidJavaObject("java.lang.String", "servicediscovery"); context.Call<UnityEngine.AndroidJavaObject>("getSystemService", arg); context.Dispose(); arg.Dispose(); c.Dispose(); _primedEvent.Set(); }); }
/** constructor */ public SoundPool() { //list this.list = new System.Collections.Generic.Dictionary <string, Item>(); //サウンドプールインスタンス。作成。 #if (UNITY_ANDROID) { this.java_soundpool = null; //読み込み最大数。 int t_max_stream = 64; #if (true) { //UsageType int t_usage_type = (int)UsageType.USAGE_GAME; //ContentType int t_content_type = (int)ContentType.CONTENT_TYPE_MUSIC; try{ UnityEngine.AndroidJavaObject t_attribute = null; { using (UnityEngine.AndroidJavaObject t_jave_attribute_builder = new UnityEngine.AndroidJavaObject("android.media.AudioAttributes$Builder")){ if (t_jave_attribute_builder != null) { t_jave_attribute_builder.Call <UnityEngine.AndroidJavaObject>("setUsage", t_usage_type); t_jave_attribute_builder.Call <UnityEngine.AndroidJavaObject>("setContentType", t_content_type); t_attribute = t_jave_attribute_builder.Call <UnityEngine.AndroidJavaObject>("build"); t_jave_attribute_builder.Dispose(); } else { Tool.Log("SoundPool", "android.media.AudioAttributes$Builder == null"); } } } if (t_attribute != null) { using (UnityEngine.AndroidJavaObject t_java_soundpool_builder = new UnityEngine.AndroidJavaObject("android.media.SoundPool$Builder")){ if (t_java_soundpool_builder != null) { t_java_soundpool_builder.Call <UnityEngine.AndroidJavaObject>("setAudioAttributes", t_attribute); t_java_soundpool_builder.Call <UnityEngine.AndroidJavaObject>("setMaxStreams", t_max_stream); this.java_soundpool = t_java_soundpool_builder.Call <UnityEngine.AndroidJavaObject>("build"); } else { Tool.Log("SoundPool", "android.media.SoundPool$Builder == null"); } } } else { Tool.Log("SoundPool", "android.media.AudioAttributes == null"); } }catch (System.Exception t_exception) { Tool.DebugReThrow(t_exception); } if (this.java_soundpool == null) { Tool.Log("SoundPool", "android.media.SoundPool == null"); } } #else { //ストリームタイプ。 int t_stream_type = (int)StreamType.STREAM_MUSIC; //0固定。 int t_src_quality = (int)SoundPoolConvertQuality.RESERVATION; this.java_soundpool = new AndroidJavaObject("android.media.SoundPool", t_max_stream, t_stream_type, t_src_quality); } #endif } #endif }