X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyCell.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacycell%2Factivities%2FPrivacyCellActivity.kt;h=091586fdf9386896a8161013ddd2825551ab1650;hp=cd0e1a1fcc10eb15355be338eb476418815f756d;hb=cb92ea552a5ffa8ca3142053660e3a73afc9240a;hpb=976d7da4c16f9ddc87f0cd7c67cd2eefc9f260b1;ds=sidebyside diff --git a/app/src/main/java/com/stoutner/privacycell/activities/PrivacyCellActivity.kt b/app/src/main/java/com/stoutner/privacycell/activities/PrivacyCellActivity.kt index cd0e1a1..091586f 100644 --- a/app/src/main/java/com/stoutner/privacycell/activities/PrivacyCellActivity.kt +++ b/app/src/main/java/com/stoutner/privacycell/activities/PrivacyCellActivity.kt @@ -55,8 +55,6 @@ import com.stoutner.privacycell.services.RealtimeMonitoringService 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. @@ -109,10 +107,6 @@ class PrivacyCellActivity : AppCompatActivity(), NavigationView.OnNavigationItem additionalNetworkInfoDetailsTextView = findViewById(R.id.additional_network_info_details) val navigationView = findViewById(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) @@ -337,6 +331,9 @@ class PrivacyCellActivity : AppCompatActivity(), NavigationView.OnNavigationItem } 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) {