Expose call foreground intents, receivers and service type contracts
This commit is contained in:
1 parent
0a48cccd9a
commit
68b922bf80
3 files changed
+11
-1
No files matched your search
@@ -23,6 +23,8 @@ class Intent() {
|
||||
extras.putAll(other.extras)
|
||||
}
|
||||
fun addFlags(value: Int) = apply { flags = flags or value }
|
||||
fun setAction(value: String) = apply { action = value }
|
||||
fun setData(value: Uri) = apply { data = value }
|
||||
fun putExtra(name: String, value: Any) = apply { extras[name] = value }
|
||||
fun getLongExtra(name: String, default: Long): Long = extras[name] as? Long ?: default
|
||||
fun getBooleanExtra(name: String, default: Boolean): Boolean = extras[name] as? Boolean ?: default
|
||||
|
||||
+5
-1
@@ -1,3 +1,7 @@
|
||||
package android.content.pm
|
||||
|
||||
object ServiceInfo { const val FOREGROUND_SERVICE_TYPE_MICROPHONE = 128 }
|
||||
object ServiceInfo {
|
||||
const val FOREGROUND_SERVICE_TYPE_MICROPHONE = 128
|
||||
const val FOREGROUND_SERVICE_TYPE_PHONE_CALL = 4
|
||||
const val FOREGROUND_SERVICE_TYPE_CAMERA = 64
|
||||
}
|
||||
+4
@@ -7,6 +7,10 @@ import java.util.concurrent.Executor
|
||||
|
||||
/** Только host-тест: разрешение Context и main-очередь, без AndroidX runtime. */
|
||||
object ContextCompat {
|
||||
const val RECEIVER_NOT_EXPORTED = Context.RECEIVER_NOT_EXPORTED
|
||||
fun startForegroundService(context: Context, intent: android.content.Intent) = context.startForegroundService(intent)
|
||||
fun registerReceiver(context: Context, receiver: android.content.BroadcastReceiver, filter: android.content.IntentFilter, flags: Int) =
|
||||
context.registerReceiver(receiver, filter, flags)
|
||||
fun checkSelfPermission(context: Context, permission: String): Int = context.checkSelfPermission(permission)
|
||||
fun getMainExecutor(context: Context): Executor = Executor { Handler(Looper.getMainLooper()).post(it) }
|
||||
}
|
||||
Reference in new issue
Block a user