class PrivacyCellActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener, PhonePermissionDialog.StoragePermissionDialogListener {
// Declare the class variables.
- private lateinit var context: Context
- private lateinit var telephonyManager: TelephonyManager
private lateinit var actionBarDrawerToggle: ActionBarDrawerToggle
// Declare the views.
additionalNetworkInfoDetailsTextView = findViewById(R.id.additional_network_info_details)
val navigationView = findViewById<NavigationView>(R.id.navigationview)
- // Get handles for the context and the telephony manager.
- context = this
- telephonyManager = getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
-
// Set the support action bar.
setSupportActionBar(toolbar)
}
private fun populatePrivacyCell(context: Context) {
+ // Get a handle for the telephony manager.
+ val telephonyManager = getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
+
// Listen to changes in the cell network state.
telephonyManager.listen(object : PhoneStateListener() {
override fun onDisplayInfoChanged(telephonyDisplayInfo: TelephonyDisplayInfo) {