예제 #1
0
 public static void SetVolume(AndroidActivity a, int audioType, int volume)
 {
     try
     {
         Set(a, "setStreamVolume", audioType, volume, 0);
     } catch (Exception ex)
     {
         log.Error(ex);
     }
 }
예제 #2
0
 /// <summary>
 /// Sets the ringer mode.
 /// Silent mode will mute the volume and will not vibrate. Vibrate mode will mute the volume and vibrate. Normal mode will be audible and may vibrate according to user settings.
 /// Parameters:
 /// See also:
 /// getRingerMode()
 /// </summary>
 /// <param name="a">activity</param>
 /// <param name="ringerMode">The ringer mode, one of RINGER_MODE_NORMAL, RINGER_MODE_SILENT, or RINGER_MODE_VIBRATE.</param>
 public static void SetRingerMode(AndroidActivity a, int ringerMode)
 {
     // setRingerMode(AudioManager.RINGER_MODE_NORMAL);
     try
     {
         Set(a, "setRingerMode", ringerMode);
     } catch (Exception ex)
     {
         log.Error(ex.Message, ex);
     }
 }
예제 #3
0
 /// <summary>
 /// Returns the current volume index for a particular stream.
 /// Parameters:
 /// streamType The stream type whose volume index is returned.
 /// Returns:
 /// The current volume index for the stream.
 /// See also:
 ///     getStreamMaxVolume(int)
 ///     setStreamVolume(int,int,int)
 /// </summary>
 /// <returns>The volume.</returns>
 /// <param name="audioType">AndroidAudioSystem.STREAM_</param>
 public static int GetVolume(AndroidActivity a, int audioType)
 {
     try
     {
         return(Get <int>(a, "getStreamVolume", 8, audioType));
     } catch (Exception ex)
     {
         log.Error(ex);
         return(0);
     }
 }
예제 #4
0
 public static void Set(AndroidActivity a, string methodName, params object[] param)
 {
     if (Application.isEditor)
     {
         return;
     }
     try
     {
         using (AndroidJavaObject audioManager = GetAudioManager(a))
         {
             audioManager.Call(methodName, param);
         }
     } catch (Exception ex)
     {
         log.Error(ex);
     }
 }
예제 #5
0
 private static AndroidJavaObject GetAudioManager(AndroidActivity a)
 {
     try
     {
         if (AUDIO_SERVICE == null)
         {
             AndroidJavaClass context = a.GetClass("android.content.Context");
             AUDIO_SERVICE = context.GetStatic <string>("AUDIO_SERVICE");
         }
         // AudioManager am = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
         return(a.Call <AndroidJavaObject>("getSystemService", AUDIO_SERVICE));
     } catch (Exception ex)
     {
         log.Error(ex);
         return(null);
     }
 }
예제 #6
0
 public static T Get <T>(AndroidActivity a, string methodName, T defValue, params object[] param)
 {
     if (Application.isEditor)
     {
         return(defValue);
     }
     try
     {
         using (AndroidJavaObject audioManager = GetAudioManager(a))
         {
             return(audioManager.Call <T>(methodName, param));
         }
     } catch (Exception ex)
     {
         log.Error(ex);
         return(defValue);
     }
 }