How to get notified when WebView starts loading a new page?


SIMMORSAL

I know how to get notified when a web page is finished loading, but is there any way to know when to start loading a new web page launched from a link from the original web page?

The reason I want it is ProgressBarto make it visible whenever the page starts to load, and make it invisible when the page finishes.

UPDATE: As mentioned, I know how to get notified when a webpage has finished loading . What I'm asking now is if it's possible to know when a new page starts to load the page. Although found from the link onPageStarted, it does work.

SIMMORSAL

To listen for a web page to start loading you should override onPageStarted, to listen to finish you should override onPageFinished, just to make it more complete use listen for errorsonReceivedError

webView.setWebViewClient(new WebViewClient() {  

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon){
            super.onPageStarted(view, url, favicon);

            // runs when a page starts loading
            progressBar.setVisibility(View.VISIBLE);
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);

            // page finishes loading
            progressBar.setVisibility(View.GONE);
        }

        @Override
        public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
            super.onReceivedError(view, request, error);

            // runs when there's a failure in loading page
            progressBar.setVisibility(View.GONE);
            Toast.makeText(context, "Failure on loading web page", Toast.LENGTH_SHORT).show();
        }
}); 

Related


How to get notified when WebView starts loading a new page?

SIMMORSAL I know how to get notified when a web page is finished loading, but is there any way to know when to start loading a new web page launched from a link from the original web page? The reason I want it is ProgressBarto make it visible whenever the page

How to get notified when WebView starts loading a new page?

SIMMORSAL I know how to get notified when a web page is finished loading, but is there any way to know when to start loading a new web page launched from a link from the original web page? The reason I want it is ProgressBarto make it visible whenever the page

How to get notified when WebView starts loading a new page?

SIMMORSAL I know how to get notified when a web page is finished loading, but is there any way to know when to start loading a new web page launched from a link from the original web page? The reason I want it is ProgressBarto make it visible whenever the page

Get notified when the service starts

Jon Salat I have a Servicedevice that scans for BLE devices. This Activityshould have shown some data collected Service. A Receiverhas been implemented to be notified when Bluetoothenabled so that we know when to start Service. It only executes if it Serviceis

How do I get notified when a Spark Streaming application starts?

Pooh_ I am using Spark 2.3 (HDP 2.3.0.2.6.5.108-1) and Spark Streaming ( JavaInputDStream). I'm writing some tests for a component using spark streaming. What I want to do is: Start the component in a separate thread, which starts spark streaming wait for it t

How do I get notified when a Spark Streaming application starts?

Pooh_ I am using Spark 2.3 (HDP 2.3.0.2.6.5.108-1) and Spark Streaming ( JavaInputDStream). I'm writing some tests for a component using spark streaming. What I want to do is: Start the component in a separate thread, which starts spark streaming wait for it t

How do I get notified when a program starts running on Linux?

victorious My computer isn't too fast and I can back up every day via Timeshift. But it's unclear what time of day the program runs. My computer slows down when it's running in the background and I don't understand why. I want to be notified when a Timeshift p

How to get notified when new messages like Facebook

Aftab Ahmad I have a chat room with up to 2 users, when one user sends a message to another user, the second user should be notified that a new message has been received like Facebook I have done it with Ajax request $(document).ready( function() {

How to get notified when new messages like Facebook

Aftab Ahmad I have a chat room with up to 2 users, when one user sends a message to another user, the second user should be notified that a new message has been received like Facebook I have done it with Ajax request $(document).ready( function() {

How to get notified when a new video file is added

creator How to detect that the camera has captured a new video. I have updated my code Updated code: public class Video extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated me

How to get notified when new messages like Facebook

Aftab Ahmad I have a chat room with up to 2 users, when one user sends a message to another user, the second user should be notified that a new message has been received like Facebook I have done it with Ajax request $(document).ready( function() {

How to get notified when a new video file is added

creator How to detect that the camera has captured a new video. I have updated my code Updated code: public class Video extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated me

How to get notified when new messages like Facebook

Aftab Ahmad I have a chat room with up to 2 users, when one user sends a message to another user, the second user should be notified that a new message has been received like Facebook I have done it with Ajax request $(document).ready( function() {

Get notified when new posts are created

Erez.info I'm looking for a way to receive notifications from Facebook when a new post is created. The only solution I've found so far is a cron job that checks every few minutes. Doesn't the Facebook SDK provide this method? thanks Oleg Subscribe using the Fa

Get notified when new posts are created

Erez.info I'm looking for a way to receive notifications from Facebook when a new post is created. The only solution I've found so far is a cron job that checks every few minutes. Doesn't the Facebook SDK provide this method? thanks Oleg Subscribe using the Fa

Get notified when http.Server starts listening

sjlee : When I look at the net/http server interface, I don't see an obvious way to notify and react when http.Server is up and starts listening : ListenAndServe(":8080", nil) The function does not return until the server is actually shut down. I've also look

Get notified when http.Server starts listening

sjlee : When I look at the net/http server interface, I don't see an obvious way to notify and react when http.Server is up and starts listening : ListenAndServe(":8080", nil) The function does not return until the server is actually shut down. I've also look

Get notified when http.Server starts listening

sjlee : When I look at the net/http server interface, I don't see an obvious way to notify and react when http.Server is up and starts listening : ListenAndServe(":8080", nil) The function does not return until the server is actually shut down. I've also look

Get notified when http.Server starts listening

sjlee : When I look at the net/http server interface, I don't see an obvious way to notify and react when http.Server is up and starts listening : ListenAndServe(":8080", nil) The function does not return until the server is actually shut down. I've also look

How to be notified when a new issue is created in YouTrack?

JG There are 10 items in our YouTrack installation. I want a new team colleague to be notified every time a new issue is created for a specific project. Is there a role similar to a project manager? Or do I have to do a custom search and subscribe to it? Mariy

How to be notified when a new issue is created in YouTrack?

JG There are 10 items in our YouTrack installation. I want a new team colleague to be notified every time a new issue is created for a specific project. Is there a role similar to a project manager? Or do I have to do a custom search and subscribe to it? Mariy

Detect when an iframe starts loading a new url

Philip: How can I detect that an iframe on a page starts loading a new page? Our situation is: When the iFrame content starts changing, we need to show the "loading" animation and hide the search box. I know how to handle the "iframe has finished loading" even

Detect when an iframe starts loading a new url

Philip: How can I detect that an iframe on a page starts loading a new page? Our situation is: When the iFrame content starts changing, we need to show the "loading" animation and hide the search box. I know how to handle the "iframe has finished loading" even

Detect when an iframe starts loading a new url

Philip: How can I detect that an iframe on a page starts loading a new page? Our situation is: When the iFrame content starts changing, we need to show the "loading" animation and hide the search box. I know how to handle the "iframe has finished loading" even