webview

kotlin Android与JavaScript如何交互

怎甘沉沦 提交于 2020-01-16 09:09:04
什么是JS交互: 说的通俗一点就是前端一些调用不了原生代码的功能,或者在一些复杂页面和混排页面上,原生没有网页来得快,所以在实际项目中,很多情况下都是原生页面掺杂着webView 加载js的网页的,这就涉及到两者之间的交互以及传值问题。 Android调用JS方法: 通过WebView的loadUrl()调用(API小于等于18使用) 通过WebView的evaluateJavascript()调用(API大于18使用) JS调用Android方法: 通过WebView的addJavascriptInterface() 通过WebViewClient的shouldOverrideUrlLoading()回调拦截url 通过 WebChromeClient 的onJsAlert()、onJsConfirm()、onJsPrompt()方法回调拦截JS对话框alert()、confirm()、prompt()方法 由于方法二和方法三使用方法复杂,大多数同学使用的都是方法一,但是方法一存在严重漏洞,这里不做过多介绍。 Android调用Js方法 1、把需要测试的js代码放到src/main/asserts文件夹下,测试代码如下 2、配置wevView属性,并写一个测试按钮进行点击监听 由于是测试,我把js代码文件放到了asserts进行加载测试,实际项目中是加载的链接,道理都一样

webview doesn't open some sites in recent versions of android

血红的双手。 提交于 2020-01-16 08:41:12
问题 I have an app that open a webview and I found that I can't open some sites in recent versions of android. Before I got the error Page not found but I was searching and I found this link where it say: android:usesCleartextTraffic Indicates whether the app intends to use cleartext network traffic, such as cleartext HTTP. The default value for apps that target API level 27 or lower is "true". Apps that target API level 28 or higher default to "false". ... So I add android:usesCleartextTraffic=

webview doesn't open some sites in recent versions of android

妖精的绣舞 提交于 2020-01-16 08:41:09
问题 I have an app that open a webview and I found that I can't open some sites in recent versions of android. Before I got the error Page not found but I was searching and I found this link where it say: android:usesCleartextTraffic Indicates whether the app intends to use cleartext network traffic, such as cleartext HTTP. The default value for apps that target API level 27 or lower is "true". Apps that target API level 28 or higher default to "false". ... So I add android:usesCleartextTraffic=

iOs orientation widht and height are smaller than it sould be

自古美人都是妖i 提交于 2020-01-16 07:42:23
问题 I have an issue running my ionic application on iOs real devices (tested on iPhone 4 and iPad 4th generation). All is woking perfectly on android phones, tablets ans iOs emulators. (This is the orientation plugin I am using: cordova-plugin-screen-orientation) My app is locked in the portrait mode and by clicking on a button I pass to another page which locks the landscape orientation. (All is going well till now) When I click the back button to return to the portrait oriented page, it rotates

Android5.1 WebView遇坑笔记-Resources$NotFoundException

老子叫甜甜 提交于 2020-01-16 06:07:04
查找原因,分析发现崩溃发生在Android版本21和22上,在网上查找资料发现下面解决方案 使用自定义WebView替换原生自带WebView解决 package com.test.test; import android.content.Context; import android.content.res.Configuration; import android.os.Build; import android.util.AttributeSet; import android.webkit.WebView; public class CustomWebView extends WebView { public CustomWebView(Context context) { super(getFixedContext(context)); } public CustomWebView(Context context, AttributeSet attrs) { super(getFixedContext(context), attrs); } public CustomWebView(Context context, AttributeSet attrs, int defStyleAttr) { super(getFixedContext(context), attrs,

android webview

一世执手 提交于 2020-01-16 05:13:59
转载请注明出处: http://blog.csdn.net/lowprofile_coding/article/details/77928614 WebView介绍 Android WebView在Android平台上是一个特殊的View, 基于webkit引擎、展现web页面的控件,这个类可以被用来在你的app中仅仅显示一张在线的网页,还可以用来开发浏览器。WebView内部实现是采用渲染引擎来展示view的内容,提供网页前进后退,网页放大,缩小,搜索。Android的Webview在低版本和高版本采用了不同的webkit版本内核,4.4后直接使用了Chrome。 现在很多APP都内置了Web网页,比如说很多电商平台,淘宝、京东、聚划算等等。WebView比较灵活,不需要升级客户端,只需要修改网页代码即可。一些经常变化的页面可以用WebView这种方式去加载网页。例如中秋节跟国庆节打开的页面不一样,如果是用WebView显示的话,只修改修改html页面就行,而不需要升级客户端。 Webview功能强大,可以直接使用html文件(本地sdcard/assets目录),还可以直接加载url,使用JavaScript可以html跟原生APP互调。 加载html四种方式 webView.loadUrl("http://139.196.35.30:8080/OkHttpTest

How to play MP3 From URL in iOS

大城市里の小女人 提交于 2020-01-16 04:05:31
问题 This question seem to duplicate with many questions. I have followed many answer in those questions already but non of them working for me. So I decided to ask this question again if you an help me. I have a URL that I get from a webview [[[webview request]URL]absoluteString]; and here is my code to play the MP3 file from URL: // properties @property (strong,nonatomic) AVPlayerItem *playerItem; @property (strong,nonatomic) AVPlayer *player; // coding NSString *decoded = (__bridge_transfer

WebView in NestedScrollView gives Fatal signal 6 (SIGABRT) code -6 RenderThread

时光总嘲笑我的痴心妄想 提交于 2020-01-16 03:01:09
问题 I have an activity with a ViewPager and TabLayout as below: <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto"> <android.support.design.widget.AppBarLayout android:id="@+id/item_appbar" android:layout_width="match_parent" android:layout_height="wrap_content"> <android.support

Android中使用WebView, WebChromeClient和WebViewClient加载网页

狂风中的少年 提交于 2020-01-16 02:07:27
在android应用中,有时要加载一个网页,如果能配上一个进度条就更好了,而android 中提供了其很好的支持,下面是一个例子程序,先帖: <?xml version="1.0" encoding="utf-8"?> <WebView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/webView" android:layout_width="fill_parent" android:layout_height="fill_parent" /> 主程序: public class WebPageLoader extends Activity { final Activity activity = this; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.getWindow().requestFeature(Window.FEATURE_PROGRESS); setContentView(R.layout.main); WebView webView = (WebView) findViewById(R.id.webView)

Android: CalledFromWrongThreadException from WebView's shouldOverrideUrlLoading

狂风中的少年 提交于 2020-01-16 00:54:24
问题 I am developing on a library that is somehow getting a CalledFromWrongThread Exception crash on Samsung Galaxy S1 (api v7 - android 2.1). The code is something like this: class MyWebViewClient extends WebViewClient { @Override public void shouldOverrideUrlLoading(WebView view, String url) { someListener.addToUiView(); } } and of course, the method that is actually throwing the error (which implements a listener callback): View v; public void addToUiView(){ v.addView(new TextView(context)); //