Skip to content

Instantly share code, notes, and snippets.

@devrath
Created October 4, 2022 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devrath/5322f4d88e0f6ec12bd363b7589b9f7c to your computer and use it in GitHub Desktop.
Save devrath/5322f4d88e0f6ec12bd363b7589b9f7c to your computer and use it in GitHub Desktop.
Deprecated static broadcast reciever
class CustomStaticBroadcastReceiver : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent) {
if (ConnectivityManager.CONNECTIVITY_ACTION == intent.action) {
Toast.makeText(context, "Connectivity changed", Toast.LENGTH_SHORT).show()
}
}
}
<receiver android:name=".demos.static_receiver.reciever.CustomStaticBroadcastReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment