mirror of
https://github.com/AeThex-Corporation/AeThex-OS.git
synced 2026-04-17 22:27:19 +00:00
fix(webview): add 1s delay and aggressive cache clear to fix black screen race condition
This commit is contained in:
parent
68d2bccb50
commit
823804c0bf
1 changed files with 11 additions and 8 deletions
|
|
@ -12,19 +12,25 @@ import com.getcapacitor.BridgeActivity;
|
|||
|
||||
import android.util.Log;
|
||||
|
||||
import android.os.Handler;
|
||||
|
||||
public class MainActivity extends BridgeActivity {
|
||||
|
||||
// Using onStart to hijack the process immediately after bridge init
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
if (this.bridge != null && this.bridge.getWebView() != null) {
|
||||
loadCustomUrl();
|
||||
// Delay loading to ensure WebView is ready and avoid race conditions
|
||||
new Handler().postDelayed(this::loadCustomUrl, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadCustomUrl() {
|
||||
WebView webView = this.bridge.getWebView();
|
||||
|
||||
runOnUiThread(() -> {
|
||||
Toast.makeText(MainActivity.this, "Resetting & Loading...", Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
|
||||
// Set WebView background to BLACK
|
||||
webView.setBackgroundColor(0xFF000000);
|
||||
|
|
@ -60,16 +66,13 @@ public class MainActivity extends BridgeActivity {
|
|||
}
|
||||
});
|
||||
|
||||
// Clear cache to ensure we aren't loading stale files
|
||||
// NUCLEAR CACHE CLEAR
|
||||
webView.clearCache(true);
|
||||
webView.clearHistory();
|
||||
webView.clearFormData();
|
||||
webView.clearSslPreferences();
|
||||
|
||||
// Force load our local test file
|
||||
// webView.loadUrl("file:///android_asset/public/test.html");
|
||||
|
||||
// SWITCH TO REAL APP
|
||||
// Using "file:///android_asset/public/" base path which matches the physical structure
|
||||
// AND ensuring we load index.html
|
||||
webView.loadUrl("file:///android_asset/public/test_red.html");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue