Scenario: In my application, as I click on the button, it opens the dialog with WebView, loads some data (that involves copying, editing and loading the HTML file locally). The WebView is expected to display the HTML file created locally.
What is happening: Dialog takes a long time to open. It waits for at least file copying and editing part. The dialog opens when WebView starts loading the HTML file.
What I have tried: I tried calling these in main thread:
url = prepareLocalHtmlFile(dataKey); //Copy and edit html file and returns its path in local dir
webView.loadUrl(url); //Show the html file in WebView
Also tried in separate thread:
Thread mThread = new Thread() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
url = prepareLocalHtmlFile(dataKey); //Copy and edit html file and returns its path in local dir
webView.loadUrl(url); //Show the html file in WebView
}
});
}
};
mThread.start();
What I want: The dialog should open immediately as soon as I press the button and then all time-consuming operations should happen (copying, editing, loading HTML in webView). Please suggest how to achieve it.