I am having a pdf url from amazon s3 bucket and I am trying to open that with my webview but it doesn't works and it shows only blank screen.
Eg Url - https://XYZwest-1.amazonaws.com/XYZ.pdf?X-Amz-Expires=86400&x-amz-security-token={TOKEN HERE}&X-Amz-Algorithm={Algorithn}Amz-Credential={AWS CREDS}&X-Amz-Date=20220815T154223Z&X-Amz-SignedHeaders=host;x-amz-security-token&X-Amz-Signature={Signature}
This is how I have my webview setup -
val settings = binding.webView.settings
// Enable java script in web view
settings.javaScriptEnabled = true
binding.webView.setLayerType(View.LAYER_TYPE_HARDWARE, null)
binding.webView.settings.domStorageEnabled = true
binding.webView.loadUrl(webUrl)
```.
Related
I'm working on an app with a custom url scheme.
It is opening some webpage for authentication in a chrome tab. This is done in xamarin forms like this:
Browser.OpenAsync(apiUrl + "mobile", new BrowserLaunchOptions
{
LaunchMode = BrowserLaunchMode.SystemPreferred,
TitleMode = BrowserTitleMode.Hide,
});
everything work as expected if I return a webpage with a link and click the the link manually:
Click here to go the app
But if i return a 302 redirect to the same url it will not close the chrome tab and dont focus the app again.
If i add a javascript in the response, it will not automatically open the url (close the chrome tab and focus the app)
I've tried things like this:
window.location = url;
window.open(url,'_self');
setTimeout(()=>window.open(url,'_self'),10);
(url is a valid variable, even tried alert(url) after changing the location and it show the correct url.
Why does it only work when I click the link manually?
In order to maintain the user's security and experience, the browser prohibits the direct use of window.open(URL) in JS to open new links.
Try to change like below:
setTimeout(()=>window.open(url,'_self'),500); //The delay time must not be too short or you will be intercepted
I've implemented a HybridWebView as described here: https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/custom-renderer/hybridwebview/
For now, I have the url hardcoded in the renderer, like this:
Control.LoadUrl("http://www.google.com");
The result is the url opens, but always in a new browser, not embedded in my ContentPage as I would expect.
Is there a Settings property on the Android.Webkit.WebView I can use to determine how it displays?
The result is the url opens, but always in a new browser, not embedded in my ContentPage as I would expect.
For android platform, it uses Android.Webkit.WebView as native control as you can see it from code:
if (Control == null) {
var webView = new Android.Webkit.WebView (Forms.Context);
webView.Settings.JavaScriptEnabled = true;
SetNativeControl (webView);
}
Then for Android.Webkit.WebView, if you don't enable the activity to handle the intent to view a web page, it is a simple web page viewer, not quite a browser yet because as soon as you click a link, the default Android Browser handles it. To enable it, this code can go anywhere following the initialization of WebView: webView.SetWebViewClient(new WebViewClient()). So you may add this code for example:
if (Control == null) {
var webView = new Android.Webkit.WebView (Forms.Context);
webView.SetWebViewClient(new WebViewClient());
webView.Settings.JavaScriptEnabled = true;
SetNativeControl (webView);
}
Usually we can also subclass WebViewClient and override ShouldOverrideUrlLoading, if it returns true, means that method has handled the URL and the event should not propagate.
I use setIconUri set a online Image URL at MediaDescriptionCompat Builder like this
MediaDescriptionCompat.Builder builder = new MediaDescriptionCompat.Builder();
builder.setMediaId(item.getlistId());
builder.setTitle(item.getlistName());
builder.setIconUri(Uri.parse(item.getlistIconM()));
Bundle bundle = new Bundle();
bundle.putInt(BUNDLE_KEY_MEDIA, R.string.title_theme);
then the Image of MediaItem display perfect at Android Auto, but not at Android Wear, why ?
and what should I do fixed this issue ?
Android Wear only loads remote URLs from https - if you are using http URLs, you should switch to https.
I'm been using the WebView in my project to show a couple of webpages in app.
On Android this works fine. but on iOS it's open the default browser insted of showing it in app, like when you use
Device.OpenUri(new Uri(e.Url))
My code look like this
webView = new WebView
{
Source = new UrlWebViewSource
{
Url = "http://www.google.com",
},
VerticalOptions = LayoutOptions.FillAndExpand
};
this.Content = webView ;
Any one here who know how to make the iOS open the page in-app ?
Using Device.OpenUri will often even according to the Xamarin documentation here, navigate outside the application.
If you want to host the content within your application, the best approach would be to embed the Webview, that it looks like your doing, and set the .Source to a url.
I don't understand why your using Device.OpenUri if you have a WebView instance already on your page.
Just set the .Source property of the WebView to point at some url.
For example:-
WebView objMyWebView = new WebView();
objMyWebView.Source = "http://www.google.com";
I have created an application using Titanium Appcelerator in which I am using a webview to show some webpages. All the webpages to be displayed in the webview are HTML5 cache enabled, as I want the webpages to be available even when the application is running offline.
The problem which I am facing is that, the webview is not able to show the cached webpages when there is no network connection. But I have tested all the webpages in the browser, and all of them are working fine.
I am facing this problem for Android platform.
This is the code for the webview:
//FirstView Component Constructor
function FirstView() {
//create object instance, a parasitic subclass of Observable
var self = Ti.UI.createView();
var webview = Ti.UI.createWebView({
url: 'http://www.w3schools.com/html/tryhtml5_html_manifest.htm'
});
self.add(webview);
return self;
}
module.exports = FirstView;
The very url is working fine in the browser. How should I solve this?
you can use local html and it use jquery .ajax for load another webpage like that
//inside local page
<div id="pull"></div>
<script>
$.ajax({
url: "http://www.w3schools.com/html/tryhtml5_html_manifest.htm",
cache: true,type: "POST"}).done(function( html ) {
$("#pull").append(html);
});
</script>