fun Context.appVersionCode(): Int
Returns the app version code, or -1 if it can't be determined. |
|
fun Context.appVersionName(): String?
Returns the app version string, or null if it can't be determined. |
|
fun Context.broadcastLocal(action: String, block: Intent.() -> Unit = {}): Unit
Sends a local broadcast by creating a new Intent with specified action, calling optional block with the instance before calling LocalBroadcastManager.sendBroadcast. fun Context.broadcastLocal(intent: Intent): Unit
Sends a local broadcast by calling LocalBroadcastManager.sendBroadcast with specified intent. |
|
val Context.connectivityManager: ConnectivityManager
Returns ConnectivityManager instance by calling Context.getSystemService. |
|
val Context.defaultSharedPreferences: SharedPreferences
Returns default SharedPreferences instance by calling PreferenceManager.getDefaultSharedPreferences. |
|
fun Context.getVectorDrawable(resId: Int): Drawable?
Helper method call to AppCompatResources.getDrawable - returns a drawable with specific resource id. Despite the name, the function this method calls will also load non-vector drawables. Will also work on pre-vector versions of the platform. |
|
val Context.inputMethodManager: InputMethodManager
Returns InputMethodManager instance by calling Context.getSystemService. |
|
val Context.isConnectedToNetwork: Boolean
Returns true if the device is connected to at least one network. Note that this doesn't necessarily indicate internet access. |
|
val Context.localBroadcastManager: LocalBroadcastManager
Returns a LocalBroadcastManager instance by calling LocalBroadcastManager.getInstance. |
|
val Context.notificationManager: NotificationManager
Returns NotificationManager instance by calling Context.getSystemService. |
|
fun Context.resolveIntAttribute(resId: Int, resolveRefs: Boolean = true): Int
Resolves an attribute with specified resource id, returning its integer value if successful. Throws an exception if attribute is invalid. |
|
fun Context.resolveIntAttributeSafe(resId: Int, resolveRefs: Boolean = true): Int?
Safe variant of Context.resolveIntAttribute. Resolves an attribute with specified resource id, returning its integer value if successful, null otherwise. |
|
val Context.searchManager: SearchManager
Returns SearchManager instance by calling Context.getSystemService. |
|
fun Context.showAlertDialog(message: String? = null, title: String? = null, block: AlertDialogBuilder.() -> Unit = {}): Dialog
Displays an alert dialog by creating a new AlertDialogBuilder using the title and message provided, then passing it to block with the builder as receiver. fun Context.showAlertDialog(messageResId: Int, titleResId: Int = 0, block: AlertDialogBuilder.() -> Unit = {}): Dialog
Displays an alert dialog by creating a new AlertDialogBuilder using the title and message string resource ids provided, then passing it to block with the builder as receiver. |
|
fun Context.showToast(messageResId: Int, duration: Int = TOAST_DEFAULT_DURATION): Unit
Creates and displays a new Toast with specified message. fun Context.showToast(message: String?, duration: Int = TOAST_DEFAULT_DURATION): Unit
|
|
fun <T : Activity> Context.startActivity(block: Intent.() -> Unit = {}): Unit
Starts a new activity by creating a new Intent, calling block with the new instance, then passing the intent to Context.startActivity. |
|
fun Context.withStyledAttributes(attrs: IntArray, set: AttributeSet? = null, defStyleAttr: Int = 0, defStyleRes: Int = 0, block: TypedArray.() -> Unit): Unit
Obtains TypedArray by calling Resources.Theme.obtainStyledAttributes with supplied parameters, then passing the array to the supplied block, before recycling it. |