android-webview

Rendering a local HTML file with a local image in WebView

雨燕双飞 提交于 2021-01-29 06:59:42
问题 I am trying to render a local html file with a local image in a WebView where the WebView is in a Dialog Box and not an Activity. The image is not being rendered, but the remainder of the info is displayed just fine. There are countless solutions to this problem suggested in Stack Overflow, many with green check marks. None that I have tried have worked. What I am doing is placing the html file and the image in res/raw The html file has a line referencing the image; I have tried different

How to get absolute compass heading on Cordova Android platform

↘锁芯ラ 提交于 2021-01-29 06:01:02
问题 I am developping an hybrid App using Cordova on Android platform. I would like to get the compass heading between my device orientation and the true North. However the 'deviceorientationabsolute' event (as documented here https://developers.google.com/web/updates/2016/03/device-orientation-changes) currently gives me the compass value relative to the initial orientation of my device. I was expecting an absolute value in reference to the true North. Using chrome console, I debugged my device

How to cache multiple URLs for a WebView Activity from Recycler View onClick

不问归期 提交于 2021-01-29 05:31:18
问题 I have setup a WebViewActivity which gets the URL from the intent. I have setup an onClickListener for my Recyclerview which opens the WebViewActivity and loads the URL. However the WebView does not cache each an every page it opens. What changes should i make in the code? WebViewActivity.java public class WebViewActivity extends AppCompatActivity { WebView myWebView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout

Youtube videos shown black screen in webView when click on play button

徘徊边缘 提交于 2021-01-29 03:32:16
问题 I tried this but it doesn't work: webView.getSettings().setJavaScriptEnabled(true); webView.loadUrl(String.valueOf("https://techx.pk/youtube-videos/")); webView.setWebViewClient(new WebViewClient(){ public boolean shouldOverrideUrlLoading(WebView view, String url){ view.loadUrl(url); return false; } }); It only plays a video but showing a black screen. 来源: https://stackoverflow.com/questions/58112959/youtube-videos-shown-black-screen-in-webview-when-click-on-play-button

CookieManager.getCookie() always returns null (Version <= API 28 (Pie))

徘徊边缘 提交于 2021-01-28 08:08:17
问题 I use a standard android.webkit.Webview in a Java-Based native android app. Inside the Webview the User logs into a webapp. After successful login the webapp stores a cookie with the access token. I want to access this cookie. The cookie has the following characteristics: HTTPS Url Structure like: https://api.example.com httpOnly Flag Secure Flag When on Android API Level 29 or API Level 30, calling CookieManager.getCookie("https://api.example.com") works like expected and returns a String

How can I call a dialog from a webview?

為{幸葍}努か 提交于 2021-01-28 05:26:27
问题 I have a webview and a class with functions that will be used with javascript inside the webview class with functions (WebAppInterface.java): public class WebAppInterface { Context mContext; WebAppInterface(Context c) { mContext = c; } @JavascriptInterface public void closeApp() { ((Activity)mContext).finishAffinity(); } @JavascriptInterface public void refresh() { Intent i = new Intent(mContext, MainActivity.class); mContext.startActivity(i); ((Activity)mContext).finish(); } } How can I call

Chrome Inspector shows Android Webview in AVD but not on actual device

一个人想着一个人 提交于 2021-01-28 03:53:23
问题 I have an Android app with a WebView which shows a simple web page. If I run the app in Android Studio's AVD (virtual device), I can inspect the WebView in Chrome Inspector. However, if I run the app on my device, I can't see the WebView. I can see Facebook (com.facebook.katana) and I can see all my Chrome tabs, but the WebView is missing. In the past, I have been able to see the WebView on my device as well but this stopped working a few weeks ago. (Developer tools are active and USB

Chrome Inspector shows Android Webview in AVD but not on actual device

坚强是说给别人听的谎言 提交于 2021-01-27 23:57:25
问题 I have an Android app with a WebView which shows a simple web page. If I run the app in Android Studio's AVD (virtual device), I can inspect the WebView in Chrome Inspector. However, if I run the app on my device, I can't see the WebView. I can see Facebook (com.facebook.katana) and I can see all my Chrome tabs, but the WebView is missing. In the past, I have been able to see the WebView on my device as well but this stopped working a few weeks ago. (Developer tools are active and USB

Listen to javascript calls of a WebView

烂漫一生 提交于 2021-01-27 20:00:35
问题 I has the following HTML <div> <input type="submit" onClick="anyJSFunction('Test')"> </div> And I open it on a WebView like: web = new WebView(this); WebSettings settings = web.getSettings(); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setSupportMultipleWindows(false); settings.setSupportZoom(false); settings.setPluginsEnabled(true); settings.setDomStorageEnabled(true); web.setVerticalScrollBarEnabled(false); web

How to disable long click on WebView in android

做~自己de王妃 提交于 2021-01-27 13:44:20
问题 I want to disable the long click on webView so I cant select the text in it, and I use three ways to do that but nothing work: 1) android:longClickable="false" 2) webView.setLongClickable(false); 3) webView.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { return true; } }); So any help please. 回答1: To disable long clicks you need to first enable long click setLongClickable(true); then the setOnLongClickListener , and return nothing: webview