当前位置: 首页>>代码示例>>Java>>正文


Java WebChromeClient类代码示例

本文整理汇总了Java中android.webkit.WebChromeClient的典型用法代码示例。如果您正苦于以下问题:Java WebChromeClient类的具体用法?Java WebChromeClient怎么用?Java WebChromeClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WebChromeClient类属于android.webkit包,在下文中一共展示了WebChromeClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onShowFileChooser

import android.webkit.WebChromeClient; //导入依赖的package包/类
public boolean onShowFileChooser(WebView view, ValueCallback<Uri[]> filePath, WebChromeClient.FileChooserParams fileChooserParams) {
    // Double check that we don't have any existing callbacks
    if (mFilePathCallback != null) {
        mFilePathCallback.onReceiveValue(null);
    }
    mFilePathCallback = filePath;

    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
        // Create the File where the photo should go
        File photoFile = null;
        try {
            photoFile = createImageFile();
            takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath);
        } catch (IOException ex) {
            // Error occurred while creating the File
            Log.e(TAG, "Unable to create Image File", ex);
        }

        // Continue only if the File was successfully created
        if (photoFile != null) {
            mCameraPhotoPath = "file:" + photoFile.getAbsolutePath();
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
                    Uri.fromFile(photoFile));
        } else {
            takePictureIntent = null;
        }
    }

    Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
    contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
    contentSelectionIntent.setType("*/*");

    Intent[] intentArray;
    if (takePictureIntent != null) {
        intentArray = new Intent[]{takePictureIntent};
    } else {
        intentArray = new Intent[0];
    }

    Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
    chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
    chooserIntent.putExtra(Intent.EXTRA_TITLE, "File Chooser");
    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);

    startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE);

    return true;

}
 
开发者ID:ashutoshbsathe,项目名称:COEP-Moodle-via-Webview,代码行数:51,代码来源:Moodle.java

示例2: initWebView

import android.webkit.WebChromeClient; //导入依赖的package包/类
private void initWebView() {
    webView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);
            if (newProgress == 100) {
                if (contentLayout != null)
                    contentLayout.showContent();
                if (webView != null)
                    url = webView.getUrl();
            } else {
                if (contentLayout != null)
                    contentLayout.showLoading();
            }
        }
    });
    webView.setWebViewClient(new WebViewClient());
    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setDomStorageEnabled(true);
    webView.getSettings().setDatabaseEnabled(true);
    webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    webView.getSettings().setAppCacheEnabled(true);

    webView.loadUrl(url);
}
 
开发者ID:lzmlsfe,项目名称:19porn,代码行数:27,代码来源:WebActivity.java

示例3: init

import android.webkit.WebChromeClient; //导入依赖的package包/类
private void init() {
    sharedPreferencesUtils = new SharedPreferencesUtils(context);
    view = LayoutInflater.from(context).inflate(R.layout.dialog_html,null);
    this.setContentView(view);
    this.setTitle(title);
    webView = (WebView) view.findViewById(R.id.dialog_html_webview);
    webView.loadDataWithBaseURL(null,readAssets(context,"about.html"),
            "text/html", "utf-8", null);
    webView.setWebChromeClient(new WebChromeClient());
    this.setPositiveButton(ok, new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
}
 
开发者ID:zzyandzzy,项目名称:captcha,代码行数:17,代码来源:HtmlDialog.java

示例4: getChromeClient

import android.webkit.WebChromeClient; //导入依赖的package包/类
private WebChromeClient getChromeClient() {
    IndicatorController mIndicatorController = (this.mIndicatorController == null) ? IndicatorHandler.getInstance().inJectProgressView(mWebCreator.offer()) : this.mIndicatorController;

    DefaultChromeClient mDefaultChromeClient =
            new DefaultChromeClient(this.mActivity, this.mIndicatorController = mIndicatorController, this.mWebChromeClient, this.mChromeClientCallbackManager, this.mIVideo = getIVideo(), mDefaultMsgConfig.getChromeClientMsgCfg(), this.mPermissionInterceptor, mWebCreator.get());

    LogUtils.i(TAG, "WebChromeClient:" + this.mWebChromeClient);
    MiddleWareWebChromeBase header = this.mMiddleWareWebChromeBaseHeader;
    if (header != null) {
        MiddleWareWebChromeBase tail = header;
        int count = 1;
        MiddleWareWebChromeBase tmp = header;
        while (tmp.next() != null) {
            tail = tmp = tmp.next();
            count++;
        }
        LogUtils.i(TAG, "MiddleWareWebClientBase middleware count:" + count);
        tail.setWebChromeClient(mDefaultChromeClient);
        return this.mTargetChromeClient = header;
    } else {
        return this.mTargetChromeClient = mDefaultChromeClient;
    }
}
 
开发者ID:Justson,项目名称:AgentWeb,代码行数:24,代码来源:AgentWeb.java

示例5: initWebView

import android.webkit.WebChromeClient; //导入依赖的package包/类
private void initWebView() {
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    /*使webview能够加载图片*/
    webSettings.setBlockNetworkImage(false);
    webSettings.setAppCacheEnabled(true);
    mDialog=new SpotsDialog(this);
    mDialog.show();
    mWebView.loadUrl(mMessage.getClickUrl());
    //        mWebAppInterface = new WebAppInterface(this);
    //        mWebView.addJavascriptInterface(mWebAppInterface, "appInterface");
    mWebView.setWebViewClient(new MyWebChromeC());
    mWebView.setWebChromeClient(new WebChromeClient(){

    });

}
 
开发者ID:yiwent,项目名称:Mobike,代码行数:18,代码来源:TripDetailActivity.java

示例6: showCustomView

import android.webkit.WebChromeClient; //导入依赖的package包/类
public void showCustomView(View view, WebChromeClient.CustomViewCallback callback) {
    // This code is adapted from the original Android Browser code, licensed under the Apache License, Version 2.0
    Log.d(TAG, "showing Custom View");
    // if a view already exists then immediately terminate the new one
    if (mCustomView != null) {
        callback.onCustomViewHidden();
        return;
    }
    
    // Store the view and its callback for later (to kill it properly)
    mCustomView = view;
    mCustomViewCallback = callback;
    
    // Add the custom view to its container.
    ViewGroup parent = (ViewGroup) this.getParent();
    parent.addView(view, COVER_SCREEN_GRAVITY_CENTER);
    
    // Hide the content view.
    this.setVisibility(View.GONE);
    
    // Finally show the custom view container.
    parent.setVisibility(View.VISIBLE);
    parent.bringToFront();
}
 
开发者ID:aabognah,项目名称:LoRaWAN-Smart-Parking,代码行数:25,代码来源:CordovaWebView.java

示例7: DefaultChromeClient

import android.webkit.WebChromeClient; //导入依赖的package包/类
DefaultChromeClient(Activity activity,
                    IndicatorController indicatorController,
                    WebChromeClient chromeClient,
                    ChromeClientCallbackManager chromeClientCallbackManager,
                    @Nullable IVideo iVideo,
                    DefaultMsgConfig.ChromeClientMsgCfg chromeClientMsgCfg, PermissionInterceptor permissionInterceptor, WebView webView) {
    super(chromeClient);
    this.mIndicatorController = indicatorController;
    isWrapper = chromeClient != null ? true : false;
    this.mWebChromeClient = chromeClient;
    mActivityWeakReference = new WeakReference<Activity>(activity);
    this.mChromeClientCallbackManager = chromeClientCallbackManager;
    this.mIVideo = iVideo;
    this.mChromeClientMsgCfg = chromeClientMsgCfg;
    this.mPermissionInterceptor = permissionInterceptor;
    this.mWebView = webView;
    mAgentWebUiController = new WeakReference<AgentWebUIController>(AgentWebUtils.getAgentWebUIControllerByWebView(webView));
    LogUtils.i(TAG, "controller:" + mAgentWebUiController.get());
}
 
开发者ID:Justson,项目名称:AgentWeb,代码行数:20,代码来源:DefaultChromeClient.java

示例8: initializeWebView

import android.webkit.WebChromeClient; //导入依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
private void initializeWebView() {
    _centerWebView = ((Activity) _context).findViewById(R.id.centerWebView);
    _centerWebView.getSettings().setBuiltInZoomControls(true);
    _centerWebView.getSettings().setSupportZoom(true);
    _centerWebView.getSettings().setJavaScriptEnabled(true);
    _centerWebView.getSettings().setLoadWithOverviewMode(true);
    _centerWebView.setWebViewClient(new WebViewClient());
    _centerWebView.setWebChromeClient(new WebChromeClient());
    _centerWebView.setInitialScale(100);
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.setAcceptCookie(false);
    _centerWebView.setWebViewClient(new WebViewClient() {
        public void onPageFinished(WebView view, String url) {
            _loadingUrl = false;
        }
    });
}
 
开发者ID:GuepardoApps,项目名称:LucaHome-AndroidApplication,代码行数:19,代码来源:CenterViewController.java

示例9: initWebView

import android.webkit.WebChromeClient; //导入依赖的package包/类
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);
}
 
开发者ID:mzlogin,项目名称:guanggoo-android,代码行数:21,代码来源:TopicDetailFragment.java

示例10: initialize

import android.webkit.WebChromeClient; //导入依赖的package包/类
private void initialize() {
    loadUrl("file:///android_asset/html/preview.html");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        getSettings().setAllowUniversalAccessFromFileURLs(true);
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
    }

    setWebChromeClient(new WebChromeClient() {
        @SuppressLint("JavascriptInterface")
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);
            if (newProgress == 100) {
                if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
                    loadUrl(mPreviewText);
                } else {
                    evaluateJavascript(mPreviewText, null);
                }
            }
        }
    });
}
 
开发者ID:GcsSloop,项目名称:diycode,代码行数:25,代码来源:MarkdownView.java

示例11: init

import android.webkit.WebChromeClient; //导入依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
private void init() {

    progressbar = new ProgressBar(getContext(), null, android.R.attr.progressBarStyleHorizontal);
    progressbar.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 20, 0, 0));
    addView(progressbar);

    WebSettings settings = getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setBuiltInZoomControls(false);
    settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    settings.setDomStorageEnabled(true);
    settings.setAppCacheEnabled(false);

    setWebChromeClient(
            new WebChromeClient() {
                @Override
                public void onProgressChanged(WebView view, int newProgress) {
                    super.onProgressChanged(view, newProgress);
                    newProgressBar(newProgress);
                }
            });
}
 
开发者ID:7449,项目名称:JsoupSample,代码行数:24,代码来源:EasyWebView.java

示例12: initParam

import android.webkit.WebChromeClient; //导入依赖的package包/类
private void initParam() {
    setUpWebViewDefaults(getView().webView);
    getView().webView.setWebViewClient(new MyWebViewClient(getView()));
    //设置显示进度条
    getView().webView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);
            if (newProgress == 100)
                getView().progressBar.setVisibility(View.GONE);
            else
                getView().progressBar.setProgress(newProgress);
        }
    });
    getView().webView.loadUrl(getView().getIntent().getStringExtra("url"));
}
 
开发者ID:zhao-mingjian,项目名称:qvod,代码行数:17,代码来源:WebViewPresenter.java

示例13: RichEditor

import android.webkit.WebChromeClient; //导入依赖的package包/类
@SuppressLint({"SetJavaScriptEnabled","addJavascriptInterface"})
public RichEditor(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    if(isInEditMode())
        return;
    
    addJavascriptInterface(new Android4JsInterface(),"AndroidInterface");
    setVerticalScrollBarEnabled(false);
    setHorizontalScrollBarEnabled(false);
    setWebViewClient(createWebViewClient());
    setWebChromeClient(new WebChromeClient());
    mContentLength = 0;
    getSettings().setJavaScriptEnabled(true);
    load();
    //applyAttributes(context, attrs);
}
 
开发者ID:nowandfurure,项目名称:richeditor,代码行数:17,代码来源:RichEditor.java

示例14: visitUrl

import android.webkit.WebChromeClient; //导入依赖的package包/类
@AfterViews
@SuppressLint("SetJavaScriptEnabled")
protected void visitUrl() {
    this.webview.setWebChromeClient(new WebChromeClient());

    // the default webview client will occasionally open the browser
    // we don't want this - we want content to be displayed,
    // by default, in the app.
    this.webview.setWebViewClient(new WebViewClient());

    // allow js
    WebSettings settings = this.webview.getSettings();

    // attempt to initially fit content without requiring zooms
    settings.setUseWideViewPort(true);
    settings.setLoadWithOverviewMode(true);

    // allow zooming
    settings.setBuiltInZoomControls(true);

    // allow js
    settings.setJavaScriptEnabled(true);

    this.webview.loadUrl(this.url);
}
 
开发者ID:AlbinoDrought,项目名称:party-reader,代码行数:26,代码来源:ExternalWebResourceActivity.java

示例15: initWebChromeClient

import android.webkit.WebChromeClient; //导入依赖的package包/类
private void initWebChromeClient() {

    mWebView.setWebChromeClient(new WebChromeClient() {

      private Bitmap mDefaultVideoPoster;//默认的视频展示图

      @Override public void onReceivedTitle(WebView view, String title) {
        super.onReceivedTitle(view, title);
        getToolBar().setTitle(title);
      }

      @Override public Bitmap getDefaultVideoPoster() {
        if (mDefaultVideoPoster == null) {
          mDefaultVideoPoster =
              BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
          return mDefaultVideoPoster;
        }
        return super.getDefaultVideoPoster();
      }
    });
  }
 
开发者ID:liuguoquan727,项目名称:android-study,代码行数:22,代码来源:WebViewUI.java


注:本文中的android.webkit.WebChromeClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。