當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。