Skip to content

Commit

Permalink
Use ContextCompat in SystemBroadcastReceiver
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsvanvelzen committed Jan 28, 2024
1 parent 2e254f7 commit b8c1c41
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.content.IntentFilter
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.ui.platform.LocalContext
import androidx.core.content.ContextCompat

@Composable
fun SystemBroadcastReceiver(
Expand All @@ -19,7 +20,7 @@ fun SystemBroadcastReceiver(
override fun onReceive(context: Context?, intent: Intent?) = onBroadcastReceive(context, intent)
}

context.registerReceiver(receiver, filter)
ContextCompat.registerReceiver(context, receiver, filter, ContextCompat.RECEIVER_NOT_EXPORTED)
onDispose { context.unregisterReceiver(receiver) }
}
}

0 comments on commit b8c1c41

Please sign in to comment.