小编Mik*_*ker的帖子

在Lollipop上使用WebView的Android同步Javascript

使用从http://www.gutterbling.com/blog/synchronous-javascript-evaluation-in-android-webview/借鉴的技术,我们已成功在我们的应用程序中实现了许多功能,允许我们的Android应用程序同步从中获取数据Webview.

这是来自gutterbling的例子:

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import android.content.Context;
import android.util.Log;
import android.webkit.WebView;


/**
 * Provides an interface for getting synchronous javascript calls
 * @author btate
 *
 */
public class SynchronousJavascriptInterface {

/** The TAG for logging. */
private static final String TAG = "SynchronousJavascriptInterface";

/** The javascript interface name for adding to web view. */
private final String interfaceName = "SynchJS";

/** Countdown latch used to wait for result. */
private CountDownLatch latch = null;

/** Return value …
Run Code Online (Sandbox Code Playgroud)

javascript android android-webview

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

标签 统计

android ×1

android-webview ×1

javascript ×1