When launching an application, the desired behavior is as follows:
- Display a splash screen while simultaneously loading a URL
- Upon the firing of a JavaScript interface event on page load, remove the splash screen
Mainactivity.java
myWebView.addJavascriptInterface(new JavaScriptInterface(this, cookieManager),"Android");
JavaScriptInterface.java
@JavascriptInterface
public void hideOrRemoveSplashScreen() {
objetcSplashScreen.doRemoveSplashScreen();
//...
}
HTML page (for pages loaded within the app, detected by User Agent)
$(function() {
try{Android.hideOrRemoveSplashScreen()}catch(e){};
});
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/pullfresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<WebView
android:id="@+id/msw_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"></WebView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
Is there a way to simultaneously load a simple .png image as a splash screen with the app and then remove it?