Java 类android.webkit.WebView 实例源码

项目:WebViewInputSample    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    webView = (WebView) findViewById(R.id.webview);
    String url = "file:///android_asset/sample.html";

    webView.getSettings().setJavaScriptEnabled(true);

    webChromeClient = new FileChooserWebChromeClient();
    webView.setWebChromeClient(webChromeClient);
    webView.loadUrl(url);

    WebView.setWebContentsDebuggingEnabled(true);

}
项目:SmartRefresh    文件:RefreshContentWrapper.java   
private View findScrollableViewInternal(View content, boolean selfable) {
    View scrollableView = null;
    Queue<View> views = new LinkedBlockingQueue<>(Collections.singletonList(content));
    while (!views.isEmpty() && scrollableView == null) {
        View view = views.poll();
        if (view != null) {
            if ((selfable || view != content) && (view instanceof AbsListView
                    || view instanceof ScrollView
                    || view instanceof ScrollingView
                    || view instanceof NestedScrollingChild
                    || view instanceof NestedScrollingParent
                    || view instanceof WebView
                    || view instanceof ViewPager)) {
                scrollableView = view;
            } else if (view instanceof ViewGroup) {
                ViewGroup group = (ViewGroup) view;
                for (int j = 0; j < group.getChildCount(); j++) {
                    views.add(group.getChildAt(j));
                }
            }
        }
    }
    return scrollableView;
}
项目:DailyZhiHu    文件:DownloadDetaiContentActivity.java   
private void init(){
    LinearLayout layout = (LinearLayout) findViewById(R.id.Download_layout);
    layout.setVisibility(View.GONE);

    Intent intent = getIntent();
    body = intent.getStringExtra("body");
    title = intent.getStringExtra("title");
    contentView = (WebView) findViewById(R.id.content_webview);
    contentView.setHorizontalScrollBarEnabled(false);//水平不显示
    contentView.setVerticalScrollBarEnabled(false); //垂直不显示

    contentView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return (event.getAction() == MotionEvent.ACTION_MOVE);
        }
    });
    contentView.setWebViewClient(new WebViewClient());

    topImage = (ImageView) findViewById(R.id.top_image);
    topTitle = (TextView) findViewById(R.id.top_titlt);
    topSource = (TextView) findViewById(R.id.top_source);
}
项目:LoRaWAN-Smart-Parking    文件:CordovaUriHelper.java   
/**
 * Give the host application a chance to take over the control when a new url
 * is about to be loaded in the current WebView.
 *
 * @param view          The WebView that is initiating the callback.
 * @param url           The url to be loaded.
 * @return              true to override, false for default behavior
 */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
boolean shouldOverrideUrlLoading(WebView view, String url) {
    // Give plugins the chance to handle the url
    if (this.appView.pluginManager.onOverrideUrlLoading(url)) {
        // Do nothing other than what the plugins wanted.
        // If any returned true, then the request was handled.
        return true;
    }
    else if(url.startsWith("file://") | url.startsWith("data:"))
    {
        //This directory on WebKit/Blink based webviews contains SQLite databases!
        //DON'T CHANGE THIS UNLESS YOU KNOW WHAT YOU'RE DOING!
        return url.contains("app_webview");
    }
    else if (appView.getWhitelist().isUrlWhiteListed(url)) {
        // Allow internal navigation
        return false;
    }
    else if (appView.getExternalWhitelist().isUrlWhiteListed(url))
    {
        try {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(url));
            intent.addCategory(Intent.CATEGORY_BROWSABLE);
            intent.setComponent(null);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
                intent.setSelector(null);
            }
            this.cordova.getActivity().startActivity(intent);
            return true;
        } catch (android.content.ActivityNotFoundException e) {
            LOG.e(TAG, "Error loading url " + url, e);
        }
    }
    // Intercept the request and do nothing with it -- block it
    return true;
}
项目:lurkerhn    文件:StoryWebViewActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_story_webview);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    final Item item = (Item) getIntent().getSerializableExtra("item");

    WebView webView = new WebView(this);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    });
    setContentView(webView);
    webView.loadUrl(item.getUrl());
}
项目:LoRaWAN-Smart-Parking    文件:CordovaUriHelper.java   
/**
 * Give the host application a chance to take over the control when a new url
 * is about to be loaded in the current WebView.
 *
 * @param view          The WebView that is initiating the callback.
 * @param url           The url to be loaded.
 * @return              true to override, false for default behavior
 */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
boolean shouldOverrideUrlLoading(WebView view, String url) {
    // Give plugins the chance to handle the url
    if (this.appView.pluginManager.onOverrideUrlLoading(url)) {
        // Do nothing other than what the plugins wanted.
        // If any returned true, then the request was handled.
        return true;
    }
    else if(url.startsWith("file://") | url.startsWith("data:"))
    {
        //This directory on WebKit/Blink based webviews contains SQLite databases!
        //DON'T CHANGE THIS UNLESS YOU KNOW WHAT YOU'RE DOING!
        return url.contains("app_webview");
    }
    else if (appView.getWhitelist().isUrlWhiteListed(url)) {
        // Allow internal navigation
        return false;
    }
    else if (appView.getExternalWhitelist().isUrlWhiteListed(url))
    {
        try {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(url));
            intent.addCategory(Intent.CATEGORY_BROWSABLE);
            intent.setComponent(null);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
                intent.setSelector(null);
            }
            this.cordova.getActivity().startActivity(intent);
            return true;
        } catch (android.content.ActivityNotFoundException e) {
            LOG.e(TAG, "Error loading url " + url, e);
        }
    }
    // Intercept the request and do nothing with it -- block it
    return true;
}
项目:hybrid-jsbridge-simple    文件:JSBridge.java   
/**
 * 获取框架api类中所有符合要求的api
 *
 * @param injectedCls
 * @return
 * @throws Exception
 */
private static HashMap<String, Method> getAllMethod(Class injectedCls) throws Exception {
    HashMap<String, Method> mMethodsMap = new HashMap<>();
    Method[] methods = injectedCls.getDeclaredMethods();
    for (Method method : methods) {
        String name;
        if (method.getModifiers() != (Modifier.PUBLIC | Modifier.STATIC) || (name = method.getName()) == null) {
            continue;
        }
        Class[] parameters = method.getParameterTypes();
        if (null != parameters && parameters.length == 4) {
            if (parameters[1] == WebView.class && parameters[2] == JSONObject.class && parameters[3] == Callback.class) {
                mMethodsMap.put(name, method);
            }
        }
    }
    return mMethodsMap;
}
项目:LoRaWAN-Smart-Parking    文件:CordovaWebViewClient.java   
/**
 * Notify the host application that a page has started loading.
 * This method is called once for each main frame load so a page with iframes or framesets will call onPageStarted
 * one time for the main frame. This also means that onPageStarted will not be called when the contents of an
 * embedded frame changes, i.e. clicking a link whose target is an iframe.
 *
 * @param view          The webview initiating the callback.
 * @param url           The url of the page.
 */
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
    super.onPageStarted(view, url, favicon);
    isCurrentlyLoading = true;
    LOG.d(TAG, "onPageStarted(" + url + ")");
    // Flush stale messages.
    this.appView.bridge.reset(url);

    // Broadcast message that page has loaded
    this.appView.postMessage("onPageStarted", url);

    // Notify all plugins of the navigation, so they can clean up if necessary.
    if (this.appView.pluginManager != null) {
        this.appView.pluginManager.onReset();
    }
}
项目:siiMobilityAppKit    文件:InAppBrowser.java   
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);

    // CB-10395 InAppBrowser's WebView not storing cookies reliable to local device storage
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        CookieManager.getInstance().flush();
    } else {
        CookieSyncManager.getInstance().sync();
    }

    // https://issues.apache.org/jira/browse/CB-11248
    view.clearFocus();
    view.requestFocus();

    try {
        JSONObject obj = new JSONObject();
        obj.put("type", LOAD_STOP_EVENT);
        obj.put("url", url);

        sendUpdate(obj, true);
    } catch (JSONException ex) {
        LOG.d(LOG_TAG, "Should never happen");
    }
}
项目:SmoothRefreshLayout    文件:ScrollCompat.java   
public static void flingCompat(View view, int velocityY) {
    if (view instanceof ScrollView) {
        ((ScrollView) view).fling(velocityY);
    } else if (view instanceof WebView) {
        ((WebView) view).flingScroll(0, velocityY);
    } else if (view instanceof RecyclerView) {
        ((RecyclerView) view).fling(0, velocityY);
    } else if (view instanceof NestedScrollView) {
        ((NestedScrollView) view).fling(velocityY);
    } else if (view instanceof AbsListView) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            ((AbsListView) view).fling(velocityY);
        } else {
            SRReflectUtil.compatOlderAbsListViewFling((AbsListView) view, velocityY);
        }
    }
}
项目:sa-android    文件:AnnouncementsArticleActivity.java   
private void fetchArticleBody() {
    setBusy(true);
    AnnouncementModels.fetchArticleBody(articleID, new ModelListener<String>() {
        @Override
        public void onData(String result, String message) {
            setBusy(false);
            if (result == null) {
                Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
            } else {
                WebView wb = (WebView) findViewById(R.id.webViewforArticle);
                wb.loadData(result, "text/html;charset=utf-8", null);
                wb.getSettings().setLoadWithOverviewMode(true);
                wb.getSettings().setUseWideViewPort(true);
            }
        }
    });
}
项目:guanggoo-android    文件:TopicDetailFragment.java   
private void initWebView() {
    mContentWebView.getSettings().setUseWideViewPort(false);
    mContentWebView.getSettings().setLoadWithOverviewMode(true);
    mContentWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
    mContentWebView.setWebChromeClient(new WebChromeClient());
    mContentWebView.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            FragmentFactory.PageType pageType = FragmentFactory.getPageTypeByUrl(url);
            if (mListener != null && pageType == FragmentFactory.PageType.VIEW_IMAGE) {
                mListener.openPage(url, getString(R.string.view_image));
                return true;
            }

            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
            return true;
        }
    });
    mContentWebView.getSettings().setJavaScriptEnabled(true);
}
项目:keemob    文件:SystemWebViewClient.java   
/**
 * On received client cert request.
 * The method forwards the request to any running plugins before using the default implementation.
 *
 * @param view
 * @param request
 */
@Override
@TargetApi(21)
public void onReceivedClientCertRequest (WebView view, ClientCertRequest request)
{

    // Check if there is some plugin which can resolve this certificate request
    PluginManager pluginManager = this.parentEngine.pluginManager;
    if (pluginManager != null && pluginManager.onReceivedClientCertRequest(null, new CordovaClientCertRequest(request))) {
        parentEngine.client.clearLoadTimeoutTimer();
        return;
    }

    // By default pass to WebViewClient
    super.onReceivedClientCertRequest(view, request);
}
项目:iosched-reader    文件:AboutUtils.java   
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    WebView webView = new WebView(getActivity());
    webView.loadUrl("file:///android_asset/licenses.html");

    return new AlertDialog.Builder(getActivity())
            .setTitle(R.string.about_licenses)
            .setView(webView)
            .setPositiveButton(R.string.ok,
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                            dialog.dismiss();
                        }
                    }
            )
            .create();
}
项目:AgentWeb    文件:AgentWebView.java   
@Override
public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) {
    Log.i(TAG,"onJsPrompt:"+url+"  message:"+message+"  d:"+defaultValue+"  ");
    if (mJsCallJavas != null && JsCallJava.isSafeWebViewCallMsg(message)) {
        JSONObject jsonObject = JsCallJava.getMsgJSONObject(message);
        String interfacedName = JsCallJava.getInterfacedName(jsonObject);
        if (interfacedName != null) {
            JsCallJava jsCallJava = mJsCallJavas.get(interfacedName);
            if (jsCallJava != null) {
                result.confirm(jsCallJava.call(view, jsonObject));
            }
        }
        return true;
    } else {
        return false;
    }

}
项目:siiMobilityAppKit    文件:SystemWebViewClient.java   
/**
 * On received client cert request.
 * The method forwards the request to any running plugins before using the default implementation.
 *
 * @param view
 * @param request
 */
@Override
@TargetApi(21)
public void onReceivedClientCertRequest (WebView view, ClientCertRequest request)
{

    // Check if there is some plugin which can resolve this certificate request
    PluginManager pluginManager = this.parentEngine.pluginManager;
    if (pluginManager != null && pluginManager.onReceivedClientCertRequest(null, new CordovaClientCertRequest(request))) {
        parentEngine.client.clearLoadTimeoutTimer();
        return;
    }

    // By default pass to WebViewClient
    super.onReceivedClientCertRequest(view, request);
}
项目:LuaViewPlayground    文件:UDWebView.java   
/**
 * Get the tile of web page
 * @return
 */
public String title() {
    WebView view = null;
    if (this.getView() != null && (view = this.getView().getWebView()) != null) {
        return view.getTitle();
    }

    return "";
}
项目:cordova-plugin-themeablebrowser-diy    文件:ThemeableBrowser.java   
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
    super.onReceivedError(view, errorCode, description, failingUrl);

    try {
        JSONObject obj = new JSONObject();
        obj.put("type", LOAD_ERROR_EVENT);
        obj.put("url", failingUrl);
        obj.put("code", errorCode);
        obj.put("message", description);

        sendUpdate(obj, true, PluginResult.Status.ERROR);
    } catch (JSONException ex) {
    }
}
项目:YFHR_Android_App    文件:contactUs.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    view= inflater.inflate(R.layout.fragment_contact_us, container, false);
    web=(WebView)view.findViewById(R.id.web_View);
    WebSettings webs =web.getSettings();
    webs.setJavaScriptEnabled(true);
    web.loadUrl(myUrl);

    web.setWebViewClient(new myWebViewClient());

    return view;
}
项目:COB    文件:SystemWebViewClient.java   
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
    try {
        // Check the against the whitelist and lock out access to the WebView directory
        // Changing this will cause problems for your application
        if (!parentEngine.pluginManager.shouldAllowRequest(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + url);
            // Results in a 404.
            return new WebResourceResponse("text/plain", "UTF-8", null);
        }

        CordovaResourceApi resourceApi = parentEngine.resourceApi;
        Uri origUri = Uri.parse(url);
        // Allow plugins to intercept WebView requests.
        Uri remappedUri = resourceApi.remapUri(origUri);

        if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
            CordovaResourceApi.OpenForReadResult result = resourceApi.openForRead(remappedUri, true);
            return new WebResourceResponse(result.mimeType, "UTF-8", result.inputStream);
        }
        // If we don't need to special-case the request, let the browser load it.
        return null;
    } catch (IOException e) {
        if (!(e instanceof FileNotFoundException)) {
            LOG.e(TAG, "Error occurred while loading a file (returning a 404).", e);
        }
        // Results in a 404.
        return new WebResourceResponse("text/plain", "UTF-8", null);
    }
}
项目:LuaViewPlayground    文件:UDWebView.java   
/**
 * Loads the given URL.
 * @param url
 * @return
 */
public UDWebView loadUrl(String url) {
    if (!TextUtils.isEmpty(url)) {
        WebView view = null;
        if (this.getView() != null && (view = this.getView().getWebView()) != null) {
            view.loadUrl(url);
        }
    }

    return this;
}
项目:studydemo    文件:WebViewActivity.java   
@Override
public void onProgressChanged(WebView view, int newProgress) {
    if(newProgress == 100){
        mProgressBar.setVisibility(View.GONE);
    }
    super.onProgressChanged(view, newProgress);
}
项目:MakiLite    文件:MessagesTouchActivity.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
    WebView.HitTestResult result = webView.getHitTestResult();
    if (result != null) {
        int type = result.getType();

        if (type == WebView.HitTestResult.IMAGE_TYPE || type == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
            showLongPressedImageMenu(menu, result.getExtra());
        }
    }
}
项目:AgentWeb    文件:SmartRefreshWebLayout.java   
public SmartRefreshWebLayout(Activity activity){

        View mView=activity.getLayoutInflater().inflate(R.layout.fragment_srl_web,null);
        View smarkView = mView.findViewById(R.id.smarkLayout);
        mSmartRefreshLayout = (SmartRefreshLayout) smarkView;
        mWebView = (WebView) mSmartRefreshLayout.findViewById(R.id.webView);

    }
项目:NullAway    文件:NullAwayNativeModels.java   
static void androidStuff() {
  android.webkit.WebView webView = new WebView();
  // BUG: Diagnostic contains: dereferenced expression
  webView.getUrl().toString();
  String s = null;
  if (!android.text.TextUtils.isEmpty(s)) {
    // no warning due to isEmpty check
    s.hashCode();
  }
}
项目:diycode    文件:GcsMarkdownViewClient.java   
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
    String url = request.getUrl().toString();
    WebResourceResponse response = getWebResourceResponse(url);
    if (response != null) return response;
    return super.shouldInterceptRequest(view, request);
}
项目:localcloud_fe    文件:SystemCookieManager.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public SystemCookieManager(WebView webview) {
    webView = webview;
    cookieManager = CookieManager.getInstance();

    //REALLY? Nobody has seen this UNTIL NOW?
    cookieManager.setAcceptFileSchemeCookies(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        cookieManager.setAcceptThirdPartyCookies(webView, true);
    }
}
项目:BackTube    文件:PlayerService.java   
@SuppressLint({"SetJavaScriptEnabled"})
@Override
public void onCreate() {
    super.onCreate();

    mWebView = new WebView(this);
    mWebView.setVerticalScrollBarEnabled(false);
    mWebView.setHorizontalScrollBarEnabled(false);
    mWebView.setBackgroundColor(Color.TRANSPARENT);
    mWebView.getSettings().setJavaScriptEnabled(true);
    {
        mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);

        mHideParams = newLayoutParams(1);

        final DisplayMetrics metrics = getResources().getDisplayMetrics();
        final int min = Math.min(metrics.heightPixels, metrics.widthPixels);

        mPlayerSize = (int) (min / metrics.density);

        mParams = newLayoutParams(min);
        mParams.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP;
        mParams.y = getTopY(metrics);
    }
    final IntentFilter filter = new IntentFilter();
    filter.addAction(ServiceAction.STOP);
    filter.addAction(ServiceAction.SHOW);
    filter.addAction(ServiceAction.HIDE);

    LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver = newBroadcastReceiver(), filter);
}
项目:siiMobilityAppKit    文件:InAppBrowser.java   
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
    super.onPageStarted(view, url, favicon);
    String newloc = "";
    if (url.startsWith("http:") || url.startsWith("https:") || url.startsWith("file:")) {
        newloc = url;
    }
    else
    {
        // Assume that everything is HTTP at this point, because if we don't specify,
        // it really should be.  Complain loudly about this!!!
        LOG.e(LOG_TAG, "Possible Uncaught/Unknown URI");
        newloc = "http://" + url;
    }

    // Update the UI if we haven't already
    if (!newloc.equals(edittext.getText().toString())) {
        edittext.setText(newloc);
     }

    try {
        JSONObject obj = new JSONObject();
        obj.put("type", LOAD_START_EVENT);
        obj.put("url", newloc);
        sendUpdate(obj, true);
    } catch (JSONException ex) {
        LOG.e(LOG_TAG, "URI passed in has caused a JSON error.");
    }
}
项目:PicShow-zhaipin    文件:H5PayDemoActivity.java   
@Override
public boolean shouldOverrideUrlLoading(final WebView view, String url) {
    if (!(url.startsWith("http") || url.startsWith("https"))) {
        return true;
    }

    final PayTask task = new PayTask(H5PayDemoActivity.this);
    final String ex = task.fetchOrderInfoFromH5PayUrl(url);
    if (!TextUtils.isEmpty(ex)) {
        System.out.println("paytask:::::" + url);
        new Thread(new Runnable() {
            public void run() {
                System.out.println("payTask:::" + ex);
                final H5PayResultModel result = task.h5Pay(ex, true);
                if (!TextUtils.isEmpty(result.getReturnUrl())) {
                    H5PayDemoActivity.this.runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            view.loadUrl(result.getReturnUrl());
                        }
                    });
                }
            }
        }).start();
    } else {
        view.loadUrl(url);
    }
    return true;
}
项目:popup-bridge-android    文件:PopupBridgeTest.java   
@Test
@SuppressLint("JavascriptInterface")
public void newInstance_addsJavascriptInterfaceToWebView() {
    WebView webView = mock(WebView.class);
    when(webView.getSettings()).thenReturn(mock(WebSettings.class));
    PopupBridge popupBridge = PopupBridge.newInstance(mActivity, webView);

    verify(webView).addJavascriptInterface(eq(popupBridge), eq("popupBridge"));
}
项目:siiMobilityAppKit    文件:InAppBrowser.java   
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
    super.onReceivedError(view, errorCode, description, failingUrl);

    try {
        JSONObject obj = new JSONObject();
        obj.put("type", LOAD_ERROR_EVENT);
        obj.put("url", failingUrl);
        obj.put("code", errorCode);
        obj.put("message", description);

        sendUpdate(obj, true, PluginResult.Status.ERROR);
    } catch (JSONException ex) {
        LOG.d(LOG_TAG, "Should never happen");
    }
}
项目:alerta-fraude    文件:SystemWebViewEngine.java   
private static void exposeJsInterface(WebView webView, CordovaBridge bridge) {
    if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)) {
        LOG.i(TAG, "Disabled addJavascriptInterface() bridge since Android version is old.");
        // Bug being that Java Strings do not get converted to JS strings automatically.
        // This isn't hard to work-around on the JS side, but it's easier to just
        // use the prompt bridge instead.
        return;
    }
    SystemExposedJsApi exposedJsApi = new SystemExposedJsApi(bridge);
    webView.addJavascriptInterface(exposedJsApi, "_cordovaNative");
}
项目:boohee_v5.6    文件:AuthActivity.java   
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    try {
        Bundle extras = getIntent().getExtras();
        if (extras == null) {
            finish();
            return;
        }
        try {
            this.d = extras.getString(b);
            String string = extras.getString("params");
            if (i.b(string)) {
                Method method;
                super.requestWindowFeature(1);
                this.f = new Handler(getMainLooper());
                View linearLayout = new LinearLayout(getApplicationContext());
                LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -1);
                linearLayout.setOrientation(1);
                setContentView(linearLayout, layoutParams);
                this.c = new WebView(getApplicationContext());
                layoutParams.weight = 1.0f;
                this.c.setVisibility(0);
                linearLayout.addView(this.c, layoutParams);
                WebSettings settings = this.c.getSettings();
                settings.setUserAgentString(settings.getUserAgentString() + i.c(getApplicationContext()));
                settings.setRenderPriority(RenderPriority.HIGH);
                settings.setSupportMultipleWindows(true);
                settings.setJavaScriptEnabled(true);
                settings.setSavePassword(false);
                settings.setJavaScriptCanOpenWindowsAutomatically(true);
                settings.setMinimumFontSize(settings.getMinimumFontSize() + 8);
                settings.setAllowFileAccess(false);
                settings.setTextSize(TextSize.NORMAL);
                this.c.setVerticalScrollbarOverlay(true);
                this.c.setWebViewClient(new b());
                this.c.setWebChromeClient(new a());
                this.c.setDownloadListener(new a(this));
                this.c.loadUrl(string);
                if (VERSION.SDK_INT >= 7) {
                    try {
                        method = this.c.getSettings().getClass().getMethod("setDomStorageEnabled", new Class[]{Boolean.TYPE});
                        if (method != null) {
                            method.invoke(this.c.getSettings(), new Object[]{Boolean.valueOf(true)});
                        }
                    } catch (Exception e) {
                    }
                }
                try {
                    method = this.c.getClass().getMethod("removeJavascriptInterface", new Class[0]);
                    if (method != null) {
                        method.invoke(this.c, new Object[]{"searchBoxJavaBridge_"});
                        method.invoke(this.c, new Object[]{"accessibility"});
                        method.invoke(this.c, new Object[]{"accessibilityTraversal"});
                        return;
                    }
                    return;
                } catch (Exception e2) {
                    return;
                }
            }
            finish();
        } catch (Exception e3) {
            finish();
        }
    } catch (Exception e4) {
        finish();
    }
}
项目:letv    文件:HongKongLoginWebview.java   
public void onProgressChanged(WebView view, int newProgress) {
    super.onProgressChanged(view, newProgress);
    if (HongKongLoginWebview.this.progressBar.getVisibility() != 0) {
        HongKongLoginWebview.this.progressBar.setVisibility(0);
    }
    HongKongLoginWebview.this.progressBar.setProgress(newProgress);
    if (newProgress == 100) {
        HongKongLoginWebview.this.progressBar.setVisibility(8);
    }
}
项目:mupdf-android-viewer-old    文件:PrintDialogActivity.java   
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
    if (url.startsWith(ZXING_URL)) {
        Intent intentScan = new Intent("com.google.zxing.client.android.SCAN");
        intentScan.putExtra("SCAN_MODE", "QR_CODE_MODE");
        try {
            startActivityForResult(intentScan, ZXING_SCAN_REQUEST);
        } catch (ActivityNotFoundException error) {
            view.loadUrl(url);
        }
    } else {
        view.loadUrl(url);
    }
    return false;
}
项目:AgentWeb    文件:WebChromeClientWrapper.java   
public void onReceivedTouchIconUrl(WebView view, String url,
                                   boolean precomposed) {
    if (this.mRealWebChromeClient != null){
        this.mRealWebChromeClient.onReceivedTouchIconUrl(view, url, precomposed);
        return ;
    }
    super.onReceivedTouchIconUrl(view,url,precomposed);
}
项目:CSipSimple    文件:Faq.java   
@Override
public void onPageFinished(final WebView view, String url) {
    super.onPageFinished(view, url);
    LinearLayout indicator = (LinearLayout) parentView.findViewById(R.id.loading_indicator);
    indicator.setVisibility(View.GONE);
    // Googlecode collapse side bar
    //view.loadUrl("javascript:$('wikisidebar').setAttribute('class', 'vt collapse');");
}
项目:GracefulMovies    文件:WebActivity.java   
@Override
public void onProgressChanged(WebView view, int newProgress) {
    super.onProgressChanged(view, newProgress);
    if (newProgress == 100) {
        mProgressBar.setVisibility(View.GONE);
    } else {
        if (mProgressBar.getVisibility() != View.VISIBLE)
            mProgressBar.setVisibility(View.VISIBLE);
        mProgressBar.setProgress(newProgress);
    }
}