Show me the code private val requestPermissionsContracts = registerForActivityResult( ActivityResultContracts.RequestMultiplePermissions() ) { permissions -> permissions.entries.forEach { if (it.key.contains("FINE")) { /** DO THINGS **/ } else { /** DO THINGS **/ } } }
Show me the code private val requestPermissionsContracts = registerForActivityResult( ActivityResultContracts.RequestMultiplePermissions() ) { permissions -> permissions.entries.forEach { if (it.key.contains("FINE")) { /** DO THINGS **/ } else { /** DO THINGS **/ } } }
Show me the code class CustomContract : ActivityResultContract() { override fun createIntent( context: Context, input: Int): Intent override fun parseResult( resultCode: Int, intent: Intent?): Boolean }
Pick a contact Contacts Get content (or more), create or open a document, open multiple documents or a document tree Content Start Activities or Intent Senders for result System Take a picture, a preview, or a video Multimedia Request one or more permissions Permissions More use cases
Show me the code class ShareComponentReceiver : BroadcastReceiver() { override fun onReceive( context: Context, intent: Intent ) { val chosenApp = intent.extras ?.get(EXTRA_CHOSEN_COMPONENT) .toString() } }
Show me the code class ShareComponentReceiver : BroadcastReceiver() { override fun onReceive( context: Context, intent: Intent ) { val chosenApp = intent.extras ?.get(EXTRA_CHOSEN_COMPONENT) .toString() } }
Show me the code private fun shareIntent() = Intent().apply { action = Intent.ACTION_SEND putExtra(Intent.EXTRA_TEXT, "Sample text to share!") type = "text/plain" }
Show me the code private fun intentSender(): IntentSender { val receiverIntent = Intent( this, ShareComponentReceiver::class.java ) val pendingIntent = PendingIntent.getBroadcast( this, 0, receiverIntent, PendingIntent.FLAG_UPDATE_CURRENT ) return pendingIntent.intentSender }
Show me the code val networkRequest = NetworkRequest.Builder() .addTransportType(NetworkCapabilities.TRANSPORT_WIFI) .removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) .setNetworkSpecifier(specifier) .build()
Show me the code val networkRequest = NetworkRequest.Builder() .addTransportType(NetworkCapabilities.TRANSPORT_WIFI) .removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) .setNetworkSpecifier(specifier) .build()
Show me the code private fun networkCallback() = object : ConnectivityManager.NetworkCallback() { override fun onAvailable(network: Network) { /** DO THINGS **/ } override fun onUnavailable() { /** DO THINGS **/ } }
Show me the code val callbacks = LifecycleListener() supportFragmentManager .registerFragmentLifecycleCallbacks(callbacks, true) supportFragmentManager .unregisterFragmentLifecycleCallbacks(callbacks)
Show me the code val biometricManager = BiometricManager.from(this) when (biometricManager.canAuthenticate()) { BiometricManager.BIOMETRIC_SUCCESS -> /** DO THINGS **/ BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE, BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE, BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED -> /** ERROR **/ }
Show me the code fun buildPromptInfo() = BiometricPrompt.PromptInfo .Builder() .setTitle("Biometric authentication sample.") .setSubtitle("I'm a subtitle.") .setDescription("I'm a description") .setNegativeButtonText("Cancel") .build()
Show me the code fun callback() = object : BiometricPrompt.AuthenticationCallback() { override fun onAuthenticationError(errorCode: Int, errString: CharSequence) { /** DO THINGS **/ } override fun onAuthenticationSucceeded(result: AuthenticationResult) { /** DO THINGS **/ } override fun onAuthenticationFailed() { /** DO THINGS **/ } }