Skip to content

Instantly share code, notes, and snippets.

@ashwin-sp
Created June 4, 2018 03:22
Show Gist options
  • Save ashwin-sp/3e97a846ba43fa798183ab4b959ede7d to your computer and use it in GitHub Desktop.
Save ashwin-sp/3e97a846ba43fa798183ab4b959ede7d to your computer and use it in GitHub Desktop.
class MyReceiver : BroadcastReceiver() {
companion object {
var CHECKED = "CHECKED"
}
override fun onReceive(context: Context, intent: Intent) {
if(intent.hasExtra(CHECKED))
{
MySliceProvider.state = intent.getBooleanExtra(CHECKED,state)
println("State at receiver $state")
val i = Intent("stateBroadcast")
i.putExtra(CHECKED, state)
context.contentResolver.notifyChange(MySliceProvider.getUri(context,"/"), null)
context.sendBroadcast(i);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment