Skip to content

Commit

Permalink
fix sharedpreferences null crash
Browse files Browse the repository at this point in the history
  • Loading branch information
jvde-github committed Jul 22, 2024
1 parent 22dc4be commit 20a9fd7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "com.jvdegithub.aiscatcher"
minSdk 23
targetSdk 34
versionCode 103
versionName '1.03'
versionCode 104
versionName '1.04'

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,11 @@ public void onPageStarted(WebView view, String url, Bitmap favicon) {
webView.setVisibility(View.INVISIBLE);

// Restore localStorage content as early as possible
String localStorageContent = getSharedPreferences().getString("localStorageContent", null);
if (localStorageContent != null) {
webView.evaluateJavascript("localStorage.setItem('settings', " + localStorageContent + ");", null);
if(getSharedPreferences()!= null) {
String localStorageContent = getSharedPreferences().getString("localStorageContent", null);
if (localStorageContent != null) {
webView.evaluateJavascript("localStorage.setItem('settings', " + localStorageContent + ");", null);
}
}
}

Expand Down

0 comments on commit 20a9fd7

Please sign in to comment.