android-webview

How do I display no internet connection popup and an html page when internet is not available for webview?

二次信任 提交于 2019-12-31 03:50:30
问题 I am using webviews in my app and want to make sure when internet is not available the pop up message displays for no internet connection and also displays an html page in the background saying internet connection required. I have added some code for checking internet connection, but its not working/ showing errors for checkmark(code added based on online research). Any clue how to fix the same? Here's the code below: public void onCreate(Bundle savedInstanceState){ super.onCreate

WebView text size

非 Y 不嫁゛ 提交于 2019-12-31 03:03:07
问题 Sometimes, when I load my page (no static content, constructed on the fly) I see the font size too small 1. If I reload I see it properly 2. I go back and forth and see it properly. And then ... small. Not a specific page, not on specific times. Not even specific version: I deploy on ICS device, no problem, then change something (like the font-size) and here is the problem. Same for deploys at 8 and 10 emulators. My view is pretty straightforward: <?xml version="1.0" encoding="utf-8"?>

How can I override Android WebView to use custom Accept-Language header?

倖福魔咒の 提交于 2019-12-31 03:02:30
问题 Is is possible to override Android WebView to use custom Accept-Language header? 回答1: The current implementation of WebView already allows you to add headers using the following syntax: Map<String, String> headers = new HashMap<String, String>(); headers.put("Accept-Language", "fr_fr"); mWebView.loadUrl("http://developer.android.com", headers); See WebView.loadUrl() for more information. 来源: https://stackoverflow.com/questions/12244375/how-can-i-override-android-webview-to-use-custom-accept

Need help changing from stock android browser to webview

南楼画角 提交于 2019-12-31 03:00:36
问题 Ok, so I've got my app done, and I'm working on minor tweaks for it, and one thing is I would prefer my web links to launch in webview instead of the stock browser... I've tried so many things and I keep getting errors and eclipse keeps launching the debug perspective and I'm stuck.. // XXXX.edu Button Button XXXX_Button = (Button)findViewById( R.id.XXXX_Button ); XXXXXX_Button.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { Uri uri = Uri.parse( "http://www

WebView Orientation change issue

筅森魡賤 提交于 2019-12-31 01:59:09
问题 I have a layout below where i have a linear layout with gravity as center to make the child center aligned.I want to add a webview programatically and loading the youtube video in it.The issue is the webview's height and width is wrap_content,wrap_content.So in portrait mode webview works fine and aligns at center but when the change the orientation to landscape web view becomes fill_parent and covers the screen horizontally so the content doesn't look at center. here is the layout file and

How to save WebView state and restore it in Android Lollipop?

梦想的初衷 提交于 2019-12-30 11:32:34
问题 This question is asked multiple times and it has answers that used to work. Recently in documentation said, they have removed this feature for security reasons. Only some limited things can be restored for the webView state. I have tried multiple ways to do it but every time it refreshes the webView state and it doesn't show the webView content. What I want to do? I have a web app that I want to retrieve the user content after time-out (If they input their credentials correct). What I have

WebView and native browser crash on simple HTML

老子叫甜甜 提交于 2019-12-30 10:55:10
问题 After struggling to find the cause of a crash in my app's WebView, I discovered that a very basic webpage causes even the native Android browser on two specific HTC models to crash. The models in question are an HTC Desire HD (Android 2.3.5) and an HTC Desire C (Android 4.0.3). Other devices have no problems loading the page, including a few other HTC models. The HTML causing the crash: <html> <body> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt

Android play youtube video in webview [closed]

蓝咒 提交于 2019-12-30 07:21:07
问题 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 3 years ago . I want to play YouTube video in WebView or When user click on youtube video I have to forward it to real YouTube app because in WebView I am not able to play YouTube video. Is there any way to play a YouTube video in our WebView? 回答1: you can play video in video view(the videos

Get the text height including the font size and set that height

≡放荡痞女 提交于 2019-12-30 06:33:27
问题 i have a text called Hello now i need to apply fontsize for this say 12 or 18 now as soon as we apply font to the text the text size increases. so now i need to get the text height including the font size using paint. i have tried with paint the following: String finalVal ="Hello"; Paint paint = new Paint(); paint.setTextSize(18); paint.setTypeface(Typeface.SANS_SERIF); paint.setColor(Color.BLACK); paint.setStyle(Paint.Style.FILL); Rect result = new Rect(); // Measure the text rectangle to

Get the text height including the font size and set that height

 ̄綄美尐妖づ 提交于 2019-12-30 06:33:14
问题 i have a text called Hello now i need to apply fontsize for this say 12 or 18 now as soon as we apply font to the text the text size increases. so now i need to get the text height including the font size using paint. i have tried with paint the following: String finalVal ="Hello"; Paint paint = new Paint(); paint.setTextSize(18); paint.setTypeface(Typeface.SANS_SERIF); paint.setColor(Color.BLACK); paint.setStyle(Paint.Style.FILL); Rect result = new Rect(); // Measure the text rectangle to