Last active
February 19, 2022 11:25
-
-
Save GiuseppeGiacoppo/cb89847438a39c7ddfd770a8219b9d8b to your computer and use it in GitHub Desktop.
Example of BaseActivity class
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
class BaseActivity: AppCompatActivity() { | |
private lateinit var logoutReceiver: BroadcastReceiver | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
logoutReceiver = LogoutReceiver() | |
registerReceiver(logoutReceiver, IntentFilter("ACTION_LOGOUT")) | |
} | |
override fun onStart() { | |
super.onStart() | |
traceEvent("Activity started") | |
} | |
override fun onStop() { | |
traceEvent("Activity stopped") | |
super.onStop() | |
} | |
private fun traceEvent(event: String) { | |
//MyAnalytics.newEvent(event) | |
} | |
inner class LogoutReceiver: BroadcastReceiver() { | |
override fun onReceive(context: Context?, intent: Intent?) { | |
finish() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment