标签: android-webview

需要帮助更新WebView的后退/前进按钮

我有一个WebView和底部的布局,后面和前面的按钮.我正在寻找一种方法来根据WebView历史记录准确设置这些按钮的启用状态.我尝试了该doUpdateVisitedHistory方法,WebViewClient但只在加载新URL时更新...不适用于链接只是向下滚动当前页面的情况,显然仍保留在WebView历史记录中.如何捕获WebView历史记录的所有附加内容?

android android-webview

1
推荐指数
1
解决办法
2134
查看次数

Android:在webview中查看内部存储文件

我有一个swf文件,它是在android的内部存储内存中创建的.

FileOutputStream fos = openFileOutput("sample.swf", Context.MODE_PRIVATE);
Run Code Online (Sandbox Code Playgroud)

有没有办法在webview的html页面中引用(嵌入)这个文件?

android android-webview

1
推荐指数
1
解决办法
2108
查看次数

姜饼上没有网页

如果我在Gingerbread Emulator上运行我的代码,它会给我:

网页不可用,以及下面列出的页面的源代码.

如果我在ICS或JB(包括phisical手机和模拟器)上运行应用程序,它确实有效:

    webview = new WebView(InterfacciaPrincipale.this);

    webview.getSettings().setBuiltInZoomControls(true);
    webview.loadData(Html.getHtml(), "text/html", "UTF-8");
    webview.getSettings().setJavaScriptEnabled(true);
    webview.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            new M("Caricamento", getApplicationContext());
            Log.v("ESSE3", "shouldOverrideUrlLoading()");
            System.out.println(url);
            try {
                Html.setHtml(Connessione.generaStringaHTML(Connessione.getUrl(url)));
            } catch (IOException e) {
                e.printStackTrace();
            }
            System.out.println(Html.getHtml());
            webview.loadDataWithBaseURL(null,Html.getHtml(), "text/html", "UTF-8",null);
            return true;

        }
    });
Run Code Online (Sandbox Code Playgroud)

是的,那里有INTERNET权限(适用于ICS和JB ......).

android webview android-webview android-2.3-gingerbread

1
推荐指数
1
解决办法
932
查看次数

在WebView中调用JavaScript函数

我知道这个问题已被多次询问,我检查了所有的解决方案并研究了一切.但是,这根本不适合我.

我不知道我做错了什么.有人可以帮帮我吗?

我正在加载一个本地html文件WebView,然后调用JavaScript函数:

wv.loadUrl("file:///android_asset/sample.html");
wv.getSettings().setJavaScriptEnabled(true);
JavascriptInterface javasriptInterface = new JavascriptInterface(MyActivity.this);
wv.addJavascriptInterface(javasriptInterface, "MyInterface");
wv.loadUrl("javascript:loadpath()");
Run Code Online (Sandbox Code Playgroud)

HTML文件是:

<html>
<head>
</head>

<body>
<script type="text/javascript">
    function callDoSomething() {
        // Do something
    }

    function loadpath() {
        // Is not called no matter whatever operation I do here. Just printing a string, setting variable, android callback anything.
        document.write("Hi");
        document.getElementById('img').src = "path.png";
    }
</script>

<form name="myForm" action="FORM">
    <img src=""  alt="Autofill" /><br>
    <input type="button" value="Submit" onClick="callDoSomething()" />
</form>

</body>
</html>
Run Code Online (Sandbox Code Playgroud)

javascript android function android-webview

1
推荐指数
1
解决办法
3495
查看次数

Android从外部存储读取html文件

我想在/ storage/sdcard0 /中显示html文件...

WebView engine = (WebView) (findViewById(R.id.webView1));
engine.setWebViewClient(new WebViewClient());
engine.loadUrl(Environment.getExternalStorageDirectory().getPath() + "testing.html");
Run Code Online (Sandbox Code Playgroud)

但网页无法显示....有人可以帮忙吗?谢谢!

android android-webview

1
推荐指数
1
解决办法
1934
查看次数

Android WebView在WebView中单击打开而不是默认浏览器?

我使用WebView做了一个示例应用程序,在该Web视图中,URL来自Web服务.它工作正常,但如果我点击该WebView中的任何链接,它会自动转到默认的Web浏览器.但我想在我的应用程序Web视图中打开.这是我的代码:

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        String url ="http://www.cementegypt.com/m/";
        WebView view =(WebView) this.findViewById(R.id.webView1);
        view.getSettings().setJavaScriptEnabled(true);
        view.loadUrl(url);
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}
Run Code Online (Sandbox Code Playgroud)

android android-webview

1
推荐指数
1
解决办法
6717
查看次数

即使在"保持类"标志之后,ProGuard也会对类进行模糊处理.影响Android WebView行为

我正在使用ProGuard来混淆我的Android应用.

我还WebView用来显示一个网页(一个HTML演练页面),其中包含一个关闭该按钮的按钮WebView.Javascript中有一个函数可以回调一个closeWalkthrough()方法:

function closeFunction()
{
    MyClass.closeWalkthrough();
}
Run Code Online (Sandbox Code Playgroud)

相关的Java类看起来像这样:

package com.myclass.android;

import android.app.Activity;
import android.content.Context;
import android.webkit.JavascriptInterface;

public class JavaScriptInterface {

    Context _context;

    JavaScriptInterface(Context context) {
        _context = context;
    }

    @JavascriptInterface
    public void closeWalkthrough() {
        ((Activity) _context).finish();
    }
}
Run Code Online (Sandbox Code Playgroud)

我在我的ProGuard文件中添加了以下标志,希望它不会混淆JavaScriptInterface类,因为如果我理解正确,Javascript方法MyClass.closeWalkthrough()正在寻找closeWalkthrough()我的JavaScriptInterfaceJava类中找到的.

...
-keepattributes JavascriptInterface
-keep public class com.myclass.android.JavaScriptInterface { *; }
...
Run Code Online (Sandbox Code Playgroud)

但是,每当我查看我的mapping.txt文件时,我都会看到它com.myclass.android.JavaScriptInterface被混淆:

...
com.myclass.android.JavaScriptInterface -> axf:
    android.content.Context _context -> a
...
Run Code Online (Sandbox Code Playgroud)

我甚至-keep …

java android proguard android-webview

1
推荐指数
1
解决办法
2040
查看次数

如何在不使用nestedScrollView的情况下在Webview滚动条上隐藏和显示FAB

这是我的XML布局中的一个浮动操作按钮。

我在NestedScrollView中的Webview导致收缩缩放支持崩溃。

<android.support.design.widget.FloatingActionButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:src="@drawable/filter_icon"
    android:tint="#FFFFFF"
    app:backgroundTint="@color/colorPrimary"
    app:elevation="4dp"
    app:fabSize="normal"
    app:useCompatPadding="true"
    app:layout_anchorGravity="bottom|end|right"
    app:layout_behavior=".ScrollAwareFABBehavior">
</android.support.design.widget.FloatingActionButton>
Run Code Online (Sandbox Code Playgroud)

android android-webview floating-action-button

1
推荐指数
1
解决办法
1990
查看次数

我的应用程序在牛轧糖操作系统中显示的Webview空白页

我在我的应用程序中称为CCAvenue付款网关集成。直到它正常工作,但是当我将设备操作系统棉花糖更新为Nougat时,Webview页面显示空白白屏。

在logcat中也找​​不到错误日志。

我还测试了低于Nougat的所有其他设备,并在该设备中测试了WebView是否正常工作。在Nougat OS中发现的唯一问题。

我已经在Google中搜索了此问题,但最近三天没有找到任何适当的解决方案。

android payment-gateway ccavenue android-webview android-7.0-nougat

1
推荐指数
1
解决办法
1743
查看次数

Android Google登录无法在WebView中使用

我是android开发的新手。尝试在Android网络视图中集成FB和Google+登录。FB登录正常。但是Google登录名不允许登录。我提到了一些链接,但无法成功。

问题是在Gmail中提供了用户名和密码后,我的网站未登录

一个WebView覆盖另一个WebView

Google登录无法正常运行的Android Webview应用

Google登录无法正常运行的Android Webview应用

private class MyCustomWebViewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        String host = Uri.parse(url).getHost();
        Log.d("Loading URL", url);
        if (host.equals(target_url_prefix)) {
            // This is my web site, so do not override; let my WebView load
            // the page
            if (mWebviewPop != null) {
                mWebviewPop.setVisibility(View.GONE);
                mContainer.removeView(mWebviewPop);
                mWebviewPop = null;
            }
            return false;
        }

        if (host.contains("m.facebook.com") || host.contains("facebook.co")
                || host.contains("google.co")
                || host.contains("www.facebook.com")
                || host.contains(".google.com")
                || host.contains(".google")
                || host.contains("accounts.google.com/signin/oauth/consent")
                || host.contains("accounts.youtube.com")
                || host.contains("accounts.google.com") …
Run Code Online (Sandbox Code Playgroud)

java android android-webview oauth-2.0 google-oauth2

1
推荐指数
3
解决办法
4740
查看次数