getSystemService method

dynamic getSystemService (String name)

Returns the handle to a system-level service by name.

The class of the returned object varies by the requested name. Returns the service or null if the name does not exist.

See: https://developer.android.com/reference/android/content/Context.html#getSystemService(java.lang.String)

Implementation

static dynamic getSystemService(final String name) {
  assert(_platform.isAndroid);
  switch (name) {
    case ACTIVITY_SERVICE:
      return ActivityManager();
    case ALARM_SERVICE:
      return AlarmManager();
    case BATTERY_SERVICE:
      return BatteryManager();
    case DOWNLOAD_SERVICE:
      return DownloadManager();
    case HARDWARE_PROPERTIES_SERVICE:
      return HardwarePropertiesManager();
    case KEYGUARD_SERVICE:
      return KeyguardManager();
    case NOTIFICATION_SERVICE:
      return NotificationManager();
    case POWER_SERVICE:
      return PowerManager();
    case SEARCH_SERVICE:
      return SearchManager();
    case USER_SERVICE:
      return UserManager();
    case VIBRATOR_SERVICE:
      return Vibrator();
    case WALLPAPER_SERVICE:
      return WallpaperManager();
    default:
      return null; // unknown service
  }
}