Created
March 24, 2022 08:32
-
-
Save Sethathi/3b0fc0d869e16e583867ca42fffb814d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Can you spot any issues with code? | |
class MyBroadcastReceiverActivity : AppCompatActivity() { | |
private var broadcastReceiver: BroadcastReceiver? = null | |
override fun onCreate(@Nullable savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_one) | |
} | |
private fun registerBroadCastReceiver() { | |
broadcastReceiver = object : BroadcastReceiver() { | |
override fun onReceive(context: Context, intent: Intent?) { | |
// Do some UI work | |
} | |
} | |
registerReceiver(broadcastReceiver, IntentFilter("currency-changed-event")) | |
} | |
override fun onStart() { | |
super.onStart() | |
registerBroadCastReceiver() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment