X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FMainWebViewActivity.java;h=61ec7af45afe85256e17d68bb694b8bcbda79126;hp=0871151183fc075d74271b1251fa296d951d5b9c;hb=65eec25c0112c1c5ba2ae0b598ee291572e24a97;hpb=8ee786ff2f0c11ebb7abcd4d51e7013c5c5a5845 diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java index 08711511..61ec7af4 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -374,6 +374,9 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // `ignorePinnedSslCertificateForDomain` is used in `onCreate()`, `onSslMismatchProceed()`, and `applyDomainSettings()`. private boolean ignorePinnedSslCertificate; + // `orbotStatusBroadcastReciever` is used in `onCreate()` and `onDestroy()`. + private BroadcastReceiver orbotStatusBroadcastReceiver; + // `waitingForOrbot` is used in `onCreate()`, `onResume()`, and `applyAppSettings()`. private boolean waitingForOrbot; @@ -565,7 +568,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook waitingForOrbot = false; // Create an Orbot status `BroadcastReceiver`. - BroadcastReceiver orbotStatusBroadcastReceiver = new BroadcastReceiver() { + orbotStatusBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // Store the content of the status message in `orbotStatus`. @@ -1173,7 +1176,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Replace the header that `WebView` creates for `X-Requested-With` with a null value. The default value is the application ID (com.stoutner.privacybrowser.standard). customHeaders.put("X-Requested-With", ""); - // Initialize the default preference values the first time the program is run. `this` is the context. `false` keeps this command from resetting any current preferences back to default. + // Initialize the default preference values the first time the program is run. `false` keeps this command from resetting any current preferences back to default. PreferenceManager.setDefaultValues(this, R.xml.preferences, false); // Get the intent that started the app. @@ -1800,6 +1803,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook @Override public void onPause() { + // Run the default commands. super.onPause(); // Pause `mainWebView`. @@ -1815,6 +1819,15 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook } } + @Override + public void onDestroy() { + // Unregister the Orbot status broadcast receiver. + this.unregisterReceiver(orbotStatusBroadcastReceiver); + + // Run the default commands. + super.onDestroy(); + } + @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present.