Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I just wanted to know how can I execute a specific action when a User navigates to an URL inside a Webview, for Example something like:
if (URL == https://google.com) {
execute Action
You need to setWebViewClient to override the urls like below -
webView.setWebViewClient(new WebViewClient() {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if ( url.startsWith("https://google.com")){
// your action
}
});
Hope this will help you.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 9 days ago.
Improve this question
My API response gets doubled every time I refresh my page. Is it because my return object is declared outside and every time I refresh it creates a new entry?
#GetMapping(value = "/getPaymentMethodDetails")
public List<AutoPayAccountBean> executePaymentMethodDetails(HttpServletRequest request) {
executeGetPaymentMethodsForUser(request);
if (Objects.nonNull(getPaymentMethodsList())) {
getPaymentMethodsList().stream().forEach(paymentMethod -> {
AutoPayAccountBean accountBean = new AutoPayAccountBean();
accountBean.setPaymentMethod(paymentMethod.getProfileName());
accountBean.setExpirationDate(expirationDate);
accountBean.setHolder(paymentMethod.getHolder());
accountBean.setStatus(paymentMethod.getStatus());
this.paymentMethodResponse.add(accountBean);
});
}
return paymentMethodResponse;
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Hi there I am trying to create app where I am using web view to show my google drive folder but whenever internet got disconnect in between loading the URL at that a msg comes with showing the URL information.
What can I do to prevent showing URL from users.
Is it possible to show some other msg whenever internet goes down on starting or when it goes down on after starting loading.
I have a custom HTML page that will show if something wrong happened when loading the url.
webView.setWebViewClient(new WebViewClient(){
#Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
switch(errorCode){
case ERROR_HOST_LOOKUP:
webView.loadDataWithBaseURL(null,"<YOUR OWN CUSTOM HTML PAGE TO SHOW WHEN THERE'S AN ERROR>", "text/html", "UTF-8",null);
break;
case ERROR_CONNECT:
webView.loadDataWithBaseURL(null,"<YOUR OWN CUSTOM HTML PAGE TO SHOW WHEN THERE'S AN ERROR>", "text/html", "UTF-8",null);
break;
case ...[IF YOU WANT TO CATCH MORE ERRORS]
}
}
}
Reference: https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedError(android.webkit.WebView,%20int,%20java.lang.String,%20java.lang.String)
Error Code Reference:
https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_AUTHENTICATION
Yes! You can either print the message or redirect the user to some other activity by checking the following method soon after the app gets launches...
DD4YouConfig dd4YouConfig = new DD4YouConfig(context);
if (dd4YouConfig.isInternetConnectivity()) {
//redirect to webview
}
else
{
//call alert dialog stating no internet
}
This is a library function so obviously don't fail to add this line in Gradle
implementation 'in.dd4you.appsconfig:appsconfig:1.3.3'
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have one question - how to write a cucumber hook that asserts the web URL.
Example -
Let's say I am testing - https://www.usatoday.com/tech/
My Given is as follows -
Given I am on the "/tech/" page
I would like a method to add the base url (www.usatoday.com) + "/tech" and assert whether it is currently on that page
(driver.getURL() ==www.usatoday/tech/)
otherwise navigate to that page if I am not there.
Any Java pros that can help me with this? Many thanks my friends.
#Given("^I am on the \"([^\"]*)\" page$")
public void i_am_on_the_page(String arg) throws throwable{
String newBaseURL = getBaseURL() + arg;
String currentURL = driver.getCurrentURL();
try{
Assert.assertEquals(newBaseURL, currentURL);
}
catch(Exception e){
driver.get(newBaseURL);
}
}
I am assuming that you have a function - getBaseURL() that will provide you the base url.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have a java selenium program that automatically presses on a button in a website. The code i am using looks like this :
driver.findElement(By.id("button")).click();
I want the program to use if statements if possible.
Thanks for your help.
Use can use findelements by along with if to achieve this. Below code might give you some idea.
if(driver.findElements(by.xpath("//*[#id=253]")).size>0)
{
//element exists with id = 253
// do the stuff
} else
{
//element do not exist with id = 253.
// do the stuff
}
Hope this helps. Thanks.
You may try this:
public void ClickButton () throws InterruptedException
{
WebElement button = driver.findElement(By.id("button"));
String Source = driver.getPageSource();
if (Source.contains(button))
{
button.click();
Thread.sleep(3000);
}
else
{
driver.quit;
}
}
Hope this can be helpful. Let me know if you are still facing problem.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have gotten all my Tournaments setup, Callbacks going ect... but I have one problem, and it is a big one: How do I initialize?
Okay, I can init for Android, no biggy, but I am looking to let this application run on both Android & iOS. So... I don't know what to do. Does not look like it is possible, but then again, maybe it is and I am blindly looking over where to do so.
Here is the page that teaches you how to Init for android & iPhone SEPARATELY, not together: https://www.nextpeer.com/how-to-make-a-basic-integration-with-nextpeer/
Like this in pseudo code;
public interface Resolver {
void init();
}
Android implements Resolver {
Android() {
new AndroidApp(new LibGDX(this));
}
init() {
// Code here
}
}
IOS implements Resolver {
IOS() {
new IOSApp(new LibGDX(this));
}
init() {
// Code here
}
}
LibGDX {
LibGDX(Resolver resolver) {
resolver.init();
}
}