Android webview not loading URL for second timeIs there a way to run Python on Android?How to save an Android Activity state using save instance state?Encode URL in JavaScript?Get current URL with jQuery?Lazy load of images in ListViewGet the current URL with JavaScript?Close/hide the Android Soft KeyboardWhy is the Android emulator so slow? How can we speed up the Android emulator?Is there a unique Android device ID?Proper use cases for Android UserManager.isUserAGoat()?

Temporarily moving a SQL Server 2016 database to SQL Server 2017 and then moving back. Is it possible?

Why are there two bearded faces wearing red hats on my stealth bomber icon?

What's the purpose of autocorrelation?

Is it possible that the shadow of The Moon is a single dot during solar eclipse?

I reverse the source code, you negate the output!

What is the origin of the "being immortal sucks" trope?

Integrability of log of distance function

What do solvers like Gurobi and CPLEX do when they run into hard instances of MIP

I was cheated into a job and want to leave ASAP, what do I tell my interviewers?

Is the Necromancer's "Half-Formed Golem" pet available for all classes?

Why do things cool down?

Why does Canada require a minimum rate of climb for ultralights of 300 ft/min?

Do liquid propellant rocket engines experience thrust oscillation?

rule-based deletions from string list

Lead Amalgam as a Material for a Sword

US entry with tourist visa but past alcohol abuse

As a discovery writer, how to complete unfinished novel (which is highly diverted from original plot ) after a time-gap

Should the pagination be reset when changing the order?

How should I avoid someone patenting technology in my paper/poster?

Quick Kurodoko Puzzle: Threes and Triples

Audire, with accusative or dative?

Do household ovens ventilate heat to the outdoors?

How do I write this symbol in latex? (disjoint sharp operator)

Simulate a 1D Game-of-Life-ish Model



Android webview not loading URL for second time


Is there a way to run Python on Android?How to save an Android Activity state using save instance state?Encode URL in JavaScript?Get current URL with jQuery?Lazy load of images in ListViewGet the current URL with JavaScript?Close/hide the Android Soft KeyboardWhy is the Android emulator so slow? How can we speed up the Android emulator?Is there a unique Android device ID?Proper use cases for Android UserManager.isUserAGoat()?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








4















I have dynamic URL that I load into a webview. I have used a WebChromeClient to handle java script events as I need to redirect the user depending on the events from the javascript in onJsAlert(). The webpage is loading for the first time. When I go back and load the same url, its loading. But, when I complete the action and receive the javascript event, I'm starting a new activity and finishing the webview activity. Now, when I load another URL, its not loading. When I kill the app and navigate to the webview activity, its loading again.



Below are my settings for the webview



 webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
webView.getSettings().setDomStorageEnabled(true);

webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setAppCacheEnabled(false);

webView.setWebViewClient(new myWebClient());
webView.setWebChromeClient(new MyJavaScriptChromeClient());
webView.loadUrl(signatureURL);
webView.setHorizontalScrollBarEnabled(false);


This is the WebViewClient I'm using to show progress dialog




public class myWebClient extends WebViewClient
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon)
// TODO Auto-generated method stub
super.onPageStarted(view, url, favicon);


@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
if (((BaseActivity) activity).checkConnection())
// TODO Auto-generated method stub
progressBar.setVisibility(View.VISIBLE);
view.loadUrl(url);

return true;



@Override
public void onPageFinished(WebView view, String url)
// TODO Auto-generated method stub
super.onPageFinished(view, url);
progressBar.setVisibility(View.GONE);


@Override
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error)
super.onReceivedError(view, request, error);
progressBar.setVisibility(View.GONE);





This is how I'm handing JS events




private class MyJavaScriptChromeClient extends WebChromeClient
@Override
public boolean onJsAlert(WebView view, String url, String message, final JsResult result)
//Check message for success/failure of payment
Log.i("message",message);
if (message.equals("Payment Fail"))
dgAlert("Payment Failed");

else if (message.equals("Payment Success"))
dgAlert("Payment Success");

return true;





This is what I'm doing on tapping OK button on the Alert Dialog



Intent intent=new Intent(Payment.this, DashBoardActivity.class);
startActivity(intent);
if (message.equals(Constants.CANCELLED))
activity.finishAffinity();
System.exit(0);
else
activity.finish();









share|improve this question
























  • I have tried by clearing history before loading URL but it didn't help.

    – rko
    Mar 29 at 8:45











  • I'm also stuck with this one. Any luck?

    – André Herculano
    Apr 10 at 16:54











  • facing the same issue? any solution?

    – Pradip Vadher
    Jul 19 at 8:51











  • same issue for api 28

    – BekaBot
    Aug 13 at 5:19

















4















I have dynamic URL that I load into a webview. I have used a WebChromeClient to handle java script events as I need to redirect the user depending on the events from the javascript in onJsAlert(). The webpage is loading for the first time. When I go back and load the same url, its loading. But, when I complete the action and receive the javascript event, I'm starting a new activity and finishing the webview activity. Now, when I load another URL, its not loading. When I kill the app and navigate to the webview activity, its loading again.



Below are my settings for the webview



 webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
webView.getSettings().setDomStorageEnabled(true);

webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setAppCacheEnabled(false);

webView.setWebViewClient(new myWebClient());
webView.setWebChromeClient(new MyJavaScriptChromeClient());
webView.loadUrl(signatureURL);
webView.setHorizontalScrollBarEnabled(false);


This is the WebViewClient I'm using to show progress dialog




public class myWebClient extends WebViewClient
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon)
// TODO Auto-generated method stub
super.onPageStarted(view, url, favicon);


@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
if (((BaseActivity) activity).checkConnection())
// TODO Auto-generated method stub
progressBar.setVisibility(View.VISIBLE);
view.loadUrl(url);

return true;



@Override
public void onPageFinished(WebView view, String url)
// TODO Auto-generated method stub
super.onPageFinished(view, url);
progressBar.setVisibility(View.GONE);


@Override
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error)
super.onReceivedError(view, request, error);
progressBar.setVisibility(View.GONE);





This is how I'm handing JS events




private class MyJavaScriptChromeClient extends WebChromeClient
@Override
public boolean onJsAlert(WebView view, String url, String message, final JsResult result)
//Check message for success/failure of payment
Log.i("message",message);
if (message.equals("Payment Fail"))
dgAlert("Payment Failed");

else if (message.equals("Payment Success"))
dgAlert("Payment Success");

return true;





This is what I'm doing on tapping OK button on the Alert Dialog



Intent intent=new Intent(Payment.this, DashBoardActivity.class);
startActivity(intent);
if (message.equals(Constants.CANCELLED))
activity.finishAffinity();
System.exit(0);
else
activity.finish();









share|improve this question
























  • I have tried by clearing history before loading URL but it didn't help.

    – rko
    Mar 29 at 8:45











  • I'm also stuck with this one. Any luck?

    – André Herculano
    Apr 10 at 16:54











  • facing the same issue? any solution?

    – Pradip Vadher
    Jul 19 at 8:51











  • same issue for api 28

    – BekaBot
    Aug 13 at 5:19













4












4








4


1






I have dynamic URL that I load into a webview. I have used a WebChromeClient to handle java script events as I need to redirect the user depending on the events from the javascript in onJsAlert(). The webpage is loading for the first time. When I go back and load the same url, its loading. But, when I complete the action and receive the javascript event, I'm starting a new activity and finishing the webview activity. Now, when I load another URL, its not loading. When I kill the app and navigate to the webview activity, its loading again.



Below are my settings for the webview



 webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
webView.getSettings().setDomStorageEnabled(true);

webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setAppCacheEnabled(false);

webView.setWebViewClient(new myWebClient());
webView.setWebChromeClient(new MyJavaScriptChromeClient());
webView.loadUrl(signatureURL);
webView.setHorizontalScrollBarEnabled(false);


This is the WebViewClient I'm using to show progress dialog




public class myWebClient extends WebViewClient
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon)
// TODO Auto-generated method stub
super.onPageStarted(view, url, favicon);


@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
if (((BaseActivity) activity).checkConnection())
// TODO Auto-generated method stub
progressBar.setVisibility(View.VISIBLE);
view.loadUrl(url);

return true;



@Override
public void onPageFinished(WebView view, String url)
// TODO Auto-generated method stub
super.onPageFinished(view, url);
progressBar.setVisibility(View.GONE);


@Override
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error)
super.onReceivedError(view, request, error);
progressBar.setVisibility(View.GONE);





This is how I'm handing JS events




private class MyJavaScriptChromeClient extends WebChromeClient
@Override
public boolean onJsAlert(WebView view, String url, String message, final JsResult result)
//Check message for success/failure of payment
Log.i("message",message);
if (message.equals("Payment Fail"))
dgAlert("Payment Failed");

else if (message.equals("Payment Success"))
dgAlert("Payment Success");

return true;





This is what I'm doing on tapping OK button on the Alert Dialog



Intent intent=new Intent(Payment.this, DashBoardActivity.class);
startActivity(intent);
if (message.equals(Constants.CANCELLED))
activity.finishAffinity();
System.exit(0);
else
activity.finish();









share|improve this question














I have dynamic URL that I load into a webview. I have used a WebChromeClient to handle java script events as I need to redirect the user depending on the events from the javascript in onJsAlert(). The webpage is loading for the first time. When I go back and load the same url, its loading. But, when I complete the action and receive the javascript event, I'm starting a new activity and finishing the webview activity. Now, when I load another URL, its not loading. When I kill the app and navigate to the webview activity, its loading again.



Below are my settings for the webview



 webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
webView.getSettings().setDomStorageEnabled(true);

webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setAppCacheEnabled(false);

webView.setWebViewClient(new myWebClient());
webView.setWebChromeClient(new MyJavaScriptChromeClient());
webView.loadUrl(signatureURL);
webView.setHorizontalScrollBarEnabled(false);


This is the WebViewClient I'm using to show progress dialog




public class myWebClient extends WebViewClient
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon)
// TODO Auto-generated method stub
super.onPageStarted(view, url, favicon);


@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
if (((BaseActivity) activity).checkConnection())
// TODO Auto-generated method stub
progressBar.setVisibility(View.VISIBLE);
view.loadUrl(url);

return true;



@Override
public void onPageFinished(WebView view, String url)
// TODO Auto-generated method stub
super.onPageFinished(view, url);
progressBar.setVisibility(View.GONE);


@Override
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error)
super.onReceivedError(view, request, error);
progressBar.setVisibility(View.GONE);





This is how I'm handing JS events




private class MyJavaScriptChromeClient extends WebChromeClient
@Override
public boolean onJsAlert(WebView view, String url, String message, final JsResult result)
//Check message for success/failure of payment
Log.i("message",message);
if (message.equals("Payment Fail"))
dgAlert("Payment Failed");

else if (message.equals("Payment Success"))
dgAlert("Payment Success");

return true;





This is what I'm doing on tapping OK button on the Alert Dialog



Intent intent=new Intent(Payment.this, DashBoardActivity.class);
startActivity(intent);
if (message.equals(Constants.CANCELLED))
activity.finishAffinity();
System.exit(0);
else
activity.finish();






javascript android webview






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 28 at 13:57









rkorko

387 bronze badges




387 bronze badges















  • I have tried by clearing history before loading URL but it didn't help.

    – rko
    Mar 29 at 8:45











  • I'm also stuck with this one. Any luck?

    – André Herculano
    Apr 10 at 16:54











  • facing the same issue? any solution?

    – Pradip Vadher
    Jul 19 at 8:51











  • same issue for api 28

    – BekaBot
    Aug 13 at 5:19

















  • I have tried by clearing history before loading URL but it didn't help.

    – rko
    Mar 29 at 8:45











  • I'm also stuck with this one. Any luck?

    – André Herculano
    Apr 10 at 16:54











  • facing the same issue? any solution?

    – Pradip Vadher
    Jul 19 at 8:51











  • same issue for api 28

    – BekaBot
    Aug 13 at 5:19
















I have tried by clearing history before loading URL but it didn't help.

– rko
Mar 29 at 8:45





I have tried by clearing history before loading URL but it didn't help.

– rko
Mar 29 at 8:45













I'm also stuck with this one. Any luck?

– André Herculano
Apr 10 at 16:54





I'm also stuck with this one. Any luck?

– André Herculano
Apr 10 at 16:54













facing the same issue? any solution?

– Pradip Vadher
Jul 19 at 8:51





facing the same issue? any solution?

– Pradip Vadher
Jul 19 at 8:51













same issue for api 28

– BekaBot
Aug 13 at 5:19





same issue for api 28

– BekaBot
Aug 13 at 5:19












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);














draft saved

draft discarded
















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55399418%2fandroid-webview-not-loading-url-for-second-time%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.




















draft saved

draft discarded















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55399418%2fandroid-webview-not-loading-url-for-second-time%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript