Android Lollipop WebView Load URL Issue - webview

When I am loading a URL in WebView for Android Lollipop 5.0, it shows a popup to choose a browser instead of showing the content in WebView itself. The same code was working fine in all earlier versions. What might be causing this?
Any help will appreciate.

this works for me
WebView webView = (WebView) findViewById(R.id.webLink);
webView.setWebViewClient(new WebViewClient());
webView.loadUrl(url);

Related

XCUITest - How to check if webview has updated its content?

I've got a webview that changes it's content when a button is pressed inside the webview. Is it possible to detect if webview has changed its content in XCUITest.
Edit: I would like a general way to know if the webview has updated without having to know the content the webview will update to–prior to the update.
Sure !
You can get your webview doing something like this:
let webview = app.webviews.firstMatch
Then, you can do some assertions on the webview content:
webview.staticTexts["TestString"].firstMatch.exists

window.location.href doesn't work with url scheme

I have a problem in iOS 8 and UIWebView. I'm running an app into webview, in this app I have an icon to call the specific url. This is url that is registered like a application url (url scheme). Then into my UIWebView, when I press the button, other view controller should be shown.
In iOS 7 the button works fine, I tap on it and my other view controller is open. But in iOS 8 when I tap on the button nothing is happening. My method to handle url actions is never called.
The web page is using "window.location.href = MyUrlScheme://...", again this is working perfectly in iOS7, but not in iOS8.
Any ideas?
You've probably found the answer to this question, but I'll leave here my solution, it may help someone. I ran into this problem today, iOS8 UIWebView does not respond to window.location.href = "MyUrlScheme://do-something"...
So I added an Iframe to the html page, set the src attribute and removed the Iframe.
var sendObjectMessage = function(parameters) {
var iframe = document.createElement('iframe');
iframe.setAttribute('src', "MyUrlScheme://"+parameters);
document.documentElement.appendChild(iframe);
iframe.parentNode.removeChild(iframe);
iframe = null;
}
sendObjectMessage("send-something");
Take a look at this link https://gist.github.com/irace/3688560

Solving Rendering Artifacts in Frame Buffer with WebView and EditText on Android 5.0?

After upgrading Nexus 5 to Android 5.0, an activity with default focus on an EditText does not render correctly (EditText repeats down across the screen with grey dots in between and if you click again or dump the ViewHierarchy with UiAutomator, it will return to normal rendering).
(I would upload the image, but don't yet have reputation for images).
NOTE: This is ONLY after I have loaded a WebView within the application (though in a separate activity). The same screen renders correctly prior to loading the first WebView in the application.
NOTE: This is ONLY a problem on Android 5.0 and (so far) on Nexus 5. I do not have another 5.0 (non-nexus) device to try.
EDIT: This also happened on HTC One with Android 5.01.
NOTE: I have tried disabling hardware acceleration, modifying inputMode, and defaultFocus.
Has anyone seen or solved this problem?
Ended up solving this by changing softInputMode (similar to previous WebView/Keyboard issues, but this time with a native View and EditText).
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
I had a similar issue on Lollipop 5.0.1 devices. My solution was to deactivate hardware acceleration in the WebView on these devices before loading any content with loadURL or loadData.
int SDKversion = android.os.Build.VERSION.SDK_INT;
if(SDKversion >= android.os.Build.VERSION_CODES.LOLLIPOP){
webview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
If you do not want to do this, I could also drastically reduce the problem by adding a visibility="gone" webview to the disturbed activities and then calling something like:
webview_dummy.loadData("<head></head><body></body>", "text/html", "utf8");
after the loadURL of the actual webview.
Man, this is really some weird bug!
What solved my problem was to disable the hardware acceleration only on the activity which hosted my fragment. Not on the whole app, but specifically on that activity.

UIWebView doesn't load

this looks very simple, but I just can't figure out what's going wrong. So what I want to do is I have a button on the 1st controller, and when the user clicks that button, I push another controller into the navigation stack and show a website in the webview.
code to push the webview controller:
SellerViewController *sellerController = [[SellerViewController alloc] initWithNibName:#"SellerViewController" bundle:nil];
[self.navigationController pushViewController:sellerController animated:YES];
code to load website
- (void)viewDidLoad
{
[super viewDidLoad];
[self.sellerWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.clickUrl]]];
}
I have a UIWebView in IB and I connect it to the outlet sellerWebView. I also checked the clickUrl, it is correct.The problem is when I click the button, the new controller shows up, but no content is loaded in the webview. Any suggestions? Thanks!
As others suggested, set a delegate and check for failure.
If your request does load and your issue is with the UIWebView's content, you can debug it, see this answer.
tl;dr:
If you're using iOS >= 6 and you have mountain lion (10.8) or Safari >= 6, you can just:
Open the application in the simulator (or your device in XCode >= 4.5.x).
Open Safari (go to Preferences -> Advanced and make sure "Show Develop Menu in Menubar" is on.
From the Menu-bar (of Safari) select Develop -> iPhone Simulator -> [your webview page].
That's it !
Edit:
Glad you found the issue. You could use Safari to catch errors having to do with invalid or wrong URLs.
One you have attached the Web Inspector to your web view, click "Inspect" on the top bar, then click "Timelines" and "Network Requests", and try to load your request.
Since you left out the http:// before the path, it would likely get prefixed with file:// instead -- you'd be able to see that it is requesting the wrong resource without guesswork.

Titanium Appcelerator - Webview issue/bug

I have some strange bug in the Titanium...
I have a window, I added a webview to the window.
Now,when I close the window & then coming back to the window
the webview is gone... :-(
Anyone ideas??
Thanks
Code:
var main = Titanium.UI.createWindow({....});
var webview = Titanium.UI.createWebView({...});
main.add(webview);
Now after those declarations:
main.close();
and after this:
main.open();
somehow the main window losing the webview...
try
main.relase(webview);
before closing and then add again on opening.
or just hide as MZ suggested.

Resources