Created
April 5, 2023 09:29
-
-
Save akshaykalola28/2bc366a8a04cd4f291b40a10cd1c8642 to your computer and use it in GitHub Desktop.
Extension function to access system service manager in android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.DownloadManager | |
import android.app.NotificationManager | |
import android.content.Context | |
import android.net.ConnectivityManager | |
import android.view.WindowManager | |
import androidx.core.content.ContextCompat | |
val Context.windowManager | |
get() = ContextCompat.getSystemService(this, WindowManager::class.java) | |
val Context.connectivityManager | |
get() = ContextCompat.getSystemService(this, ConnectivityManager::class.java) | |
val Context.notificationManager | |
get() = ContextCompat.getSystemService(this, NotificationManager::class.java) | |
val Context.downloadManager | |
get() = ContextCompat.getSystemService(this, DownloadManager::class.java) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment