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


Java WebView.setWebChromeClient方法代码示例

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


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

示例1: clearWebView

import android.webkit.WebView; //导入方法依赖的package包/类
static final void clearWebView(WebView m) {

        if (m == null)
            return;
        if (Looper.myLooper() != Looper.getMainLooper())
            return;
        m.loadUrl("about:blank");
        m.stopLoading();
        if (m.getHandler() != null)
            m.getHandler().removeCallbacksAndMessages(null);
        m.removeAllViews();
        ViewGroup mViewGroup = null;
        if ((mViewGroup = ((ViewGroup) m.getParent())) != null)
            mViewGroup.removeView(m);
        m.setWebChromeClient(null);
        m.setWebViewClient(null);
        m.setTag(null);
        m.clearHistory();
        m.destroy();
        m = null;


    }
 
开发者ID:Justson,项目名称:AgentWeb,代码行数:24,代码来源:AgentWebUtils.java

示例2: onCreate

import android.webkit.WebView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_webview);

    WebView webview = (WebView) findViewById(R.id.webview);


    webview.getSettings().setJavaScriptEnabled(true);
    webview.getSettings().setBuiltInZoomControls(false);
    webview.getSettings().setSupportZoom(true);
    webview.getSettings().setUseWideViewPort(true);
    webview.getSettings().setLoadWithOverviewMode(true);
    webview.getSettings().setSupportMultipleWindows(true);
    webview.setWebChromeClient(new WebChromeClient());
    webview.setWebViewClient(new MyWebChromeClient());

    webview.loadUrl("file:///android_asset/abc.html");
}
 
开发者ID:BaoBaoJianqiang,项目名称:HybridForAndroid,代码行数:20,代码来源:WebViewActivity.java

示例3: init

import android.webkit.WebView; //导入方法依赖的package包/类
private void init() {
    mWebView = (WebView) findViewById(R.id.news_webview);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    mWebView.setWebViewClient(new WebViewClient());
    mWebView.setWebChromeClient(new WebChromeClient(){
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            if (newProgress == 100) {
                closeDialog();
            } else {
                openLoadingDialog(newProgress);
            }
        }
    });

}
 
开发者ID:AndroidWJC,项目名称:UnversityFinance,代码行数:18,代码来源:WebViewActivity.java

示例4: init

import android.webkit.WebView; //导入方法依赖的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

示例5: onCreate

import android.webkit.WebView; //导入方法依赖的package包/类
@Override
public void onCreate() {
    mHandler = new Handler();
    mWebview = new WebView(this);
    mWebview.getSettings().setJavaScriptEnabled(true);
    mWebview.setWebChromeClient(new WebChromeClient());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        WebView.setWebContentsDebuggingEnabled(true);
    }
    mWebview.addJavascriptInterface(new BlocklyJavascriptInterface(),
            "BlocklyJavascriptInterface");

    mWebview.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageFinished(WebView view, String url) {
            synchronized (this) {
                mReady = true;
            }
            handleRequest();
        }
    });
    mWebview.loadUrl(BLOCKLY_COMPILER_PAGE);
}
 
开发者ID:Axe-Ishmael,项目名称:Blockly,代码行数:24,代码来源:CodeGeneratorService.java

示例6: onCreate

import android.webkit.WebView; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceBundle) {
    super.onCreate(savedInstanceBundle);

    setContentView(R.layout.li_login_activity);
    Intent intent = getIntent();
    Toolbar toolbar = (Toolbar) findViewById(R.id.li_toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    service = new LiAuthServiceImpl(this);

    webViewOauth = (WebView) findViewById(R.id.li_web_oauth);
    progBar = (ProgressBar) findViewById(R.id.li_login_page_prog_bar);
    loginInProgTxt = (TextView) findViewById(R.id.li_login_in_prog_txt);
    String authUrl = intent.getData().toString();
    progBar.setVisibility(View.VISIBLE);
    webViewOauth.setVisibility(View.INVISIBLE);
    loginInProgTxt.setText(getString(R.string.li_openingLoginPage));
    loginInProgTxt.setVisibility(View.VISIBLE);
    isAccessTokenSaved = false;
    webViewOauth.clearHistory();
    webViewOauth.clearFormData();
    webViewOauth.clearCache(true);
    setTitle(authUrl);
    //set the web client
    webViewOauth.setWebViewClient(new LoginWebViewClient());
    webViewOauth.setWebChromeClient(new LoginWebChromeClient());
    //activates JavaScript (just in case)
    WebSettings webSettings = webViewOauth.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    webSettings.setAppCacheEnabled(false);
    //load the url of the oAuth login page
    webViewOauth.loadUrl(authUrl);
}
 
开发者ID:lithiumtech,项目名称:li-android-sdk-core,代码行数:36,代码来源:LiLoginActivity.java

示例7: onCreate

import android.webkit.WebView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_noticia);

    //Pega a notícia passada pela ActivityPrincipal
    mNoticia = (Noticia)getIntent().getExtras().get("noticia");

    //Obtem da View
    mToolbar = (Toolbar) findViewById(R.id.tb_noticias);
    mToolbar.setTitle(mNoticia.getTitulo());
    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });

    //Obtem da View
    mImageView = (ImageView) findViewById(R.id.iv_noticias);
    //Carrega a imagem com a biblioteca Picasso
    Picasso.with(this).load(Uri.parse(Utils.getUrlApiThumbnail(this).replace("$tipo", "noticias").replace("$id", String.valueOf(mNoticia.getId()))+"&thumb=false")).placeholder(R.drawable.no_avatar).into(mImageView);

    //Obtem da View
    mWebView = (WebView) findViewById(R.id.web_noticias);
    //Carrega o conteúdo
    mWebView.loadDataWithBaseURL("file:///android_asset/","<link rel=\"stylesheet\" type=\"text/css\" href=\"estilo.css\" />"+mNoticia.getConteudo(),"text/html", "UTF-8", null);
    //Permite Javascript e outros fatores
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setAllowContentAccess(true);
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setPluginState(WebSettings.PluginState.ON);
    webSettings.setUseWideViewPort(true);
    mWebView.setWebChromeClient(new WebChromeClient() {});
}
 
开发者ID:alessandrojean,项目名称:order-by-android,代码行数:39,代码来源:ViewNoticia.java

示例8: onCreate

import android.webkit.WebView; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Window window = getWindow();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        window.setStatusBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
    }
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    mWebView = new WebView(this);
    mWebView.setScrollContainer(false);
    ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    setContentView(mWebView, layoutParams);

    Bundle args = getIntent().getExtras();
    String url = args.getString(ARG_URL);

    mWebView.setWebViewClient(new WebViewClient());
    mWebView.getSettings().setJavaScriptEnabled(true);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        mWebView.getSettings().setMediaPlaybackRequiresUserGesture(false);
    }
    mWebView.setWebChromeClient(new WebChromeClient());
    mWebView.loadUrl(url);
}
 
开发者ID:qqq3,项目名称:inventum,代码行数:28,代码来源:VideoActivity.java

示例9: MobclickAgentJSInterface

import android.webkit.WebView; //导入方法依赖的package包/类
public MobclickAgentJSInterface(Context context, WebView webView) {
    this.a = context;
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setWebChromeClient(new a(this, null));
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:6,代码来源:MobclickAgentJSInterface.java

示例10: onCreate

import android.webkit.WebView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_web2);
    mWebView = (WebView) findViewById(R.id.webview2);
    mProgressBar = (ProgressBar) findViewById(R.id.web_progressbar);

    Intent intent = getIntent();
    String url = intent.getStringExtra("url");

    mWebView.setWebChromeClient(new MyWebChromeClient());
    mWebView.setWebViewClient(webViewClient);
    mWebView.loadUrl(url);
}
 
开发者ID:zwf779375807,项目名称:progresswebview,代码行数:15,代码来源:Web2Activity.java

示例11: onCreate

import android.webkit.WebView; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@SuppressLint("SetJavaScriptEnabled")
@Override
/**
 * When the dialog is created, we add the webview and load the authorize url.
 */
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	
	mProgress = new ProgressDialog(getContext());
	mProgress.requestWindowFeature(Window.FEATURE_NO_TITLE);
	mProgress.setMessage("Loading...");
	
	mLayout = new LinearLayout(getContext());
	mLayout.setOrientation(LinearLayout.VERTICAL);

	mWebView = new WebView(getContext());
	mWebView.setVerticalScrollBarEnabled(false);
	mWebView.setHorizontalScrollBarEnabled(false);
	//mWebView.getSettings().setSupportZoom(false);
	mWebView.setLayoutParams(MATCH);
	mWebView.getSettings().setJavaScriptEnabled(true);

	mWebView.setWebViewClient(new OAuthWebViewClient());
       mWebView.setWebChromeClient(new WebChromeClient());
       
       mWebView.loadUrl(mReq.getLocationUri());
       mLayout.addView(mWebView);
       
       Display display = getWindow().getWindowManager().getDefaultDisplay();
	addContentView(mLayout, new FrameLayout.LayoutParams(display.getWidth() - 20, display.getHeight() - 20));
	CookieSyncManager.createInstance(getContext());
	CookieManager cookieManager = CookieManager.getInstance();
	cookieManager.removeAllCookie();
	
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:39,代码来源:OAuthDialog.java

示例12: initWebView

import android.webkit.WebView; //导入方法依赖的package包/类
private void initWebView() {
        wvWeb = (WebView) findViewById(R.id.wv_web);
        wvWeb.setWebChromeClient(new WebChromeClient() {
            @Override
            public void onProgressChanged(WebView view, int newProgress) {
                super.onProgressChanged(view, newProgress);
                if (newProgress == 100) {
                    fl.setVisibility(View.GONE);
                    url = wvWeb.getUrl();
                } else {
                    fl.setVisibility(View.VISIBLE);
                }
            }
        });

        wvWeb.setWebViewClient(new WebViewClient());
        wvWeb.getSettings().setBuiltInZoomControls(false);
        wvWeb.getSettings().setJavaScriptEnabled(true);
        wvWeb.getSettings().setDomStorageEnabled(true);
        wvWeb.getSettings().setDatabaseEnabled(true);
//        wvWeb.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
        wvWeb.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);  //设置 缓存模式
        String cacheDirPath = getFilesDir().getAbsolutePath();
        //      String cacheDirPath = getCacheDir().getAbsolutePath()+Constant.APP_DB_DIRNAME;
        //设置数据库缓存路径
        wvWeb.getSettings().setDatabasePath(cacheDirPath);
        //设置  Application Caches 缓存目录
        wvWeb.getSettings().setAppCachePath(cacheDirPath);
        wvWeb.getSettings().setAppCacheEnabled(true);


        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
            Log.i("log", "initWebView: --------------  1");
            wvWeb.evaluateJavascript("document.body.style.backgroundColor=\"black\";document.body.style.color=\"white\";", null);
        } else {
            Log.i("log", "initWebView: --------------  2");
            wvWeb.loadUrl("javascript:document.body.style.backgroundColor=\"#black\";document.body.style.color=\"white\";");
        }
        wvWeb.loadUrl(url);



    }
 
开发者ID:lueans,项目名称:LueansRead,代码行数:44,代码来源:WebActivity.java

示例13: onCreate

import android.webkit.WebView; //导入方法依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    listeners = new ArrayList<>();
    progressListeners = new ArrayList<>();
    webView = new WebView(this);
    webView.setWebViewClient(new WebClient(this));
    webView.setWebChromeClient(new ChromeClient(this));
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setLoadsImagesAutomatically(false);
    webSettings.setUserAgentString("Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/4.0");
}
 
开发者ID:TheAndroidMaster,项目名称:Blackboard,代码行数:15,代码来源:Blackboard.java

示例14: onCreate

import android.webkit.WebView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.place_details);
    mContext = this;
    mResources = getResources();
    
    mMapFragment = (SupportMapFragment)
            getSupportFragmentManager().findFragmentById(R.id.place_map);
    
    mMapFragment.getMapAsync(new OnMapReadyCallback() {
        @Override
        public void onMapReady(GoogleMap map) {
            mMap = map;
            updateUI();
        }
    });
    
    mPlaceId = getIntent().getIntExtra(EXTRA_PLACE_POSITION, -1);
    final VisitableGenerator generator = VisitableGenerator.get(this);
    mPlace = generator.getPlace(mPlaceId);
    mLocation = new Location("");
    mLocation.set(mPlace.getLocation());
    
    mPlaceImageViewFull = (ImageView) findViewById(R.id.place_image_full);
    mPlaceCaption = (TextView) findViewById(R.id.place_caption_full);
    mWebView = (WebView) findViewById(R.id.web_view);
    mBackupEmptyView = (TextView) findViewById(R.id.place_backup_empty_view);
    mIndicator = (ProgressBar) findViewById(R.id.indicator);
    mVisitedCheckBox = (CheckBox) findViewById(R.id.visited_check_box);
    
    mProgressBar = (ProgressBar) findViewById(R.id.progress_bar);
    mProgressBar.setMax(100);
    
    mWebView.setWebChromeClient(new WebChromeClient() {
        
        @Override
        public void onProgressChanged(WebView webView, int newProgress) {
            if (newProgress == 100) {
                mProgressBar.setVisibility(View.GONE);
            } else {
                mProgressBar.setVisibility(View.VISIBLE);
                mProgressBar.setProgress(newProgress);
            }
        }
    });
    mWebView.setWebViewClient(new WebViewClient());
    mWebView.loadUrl(mPlace.getWikiUrl());
    
    Bitmap bitmap = PictureUtils.decodeBitmapFromResource(getResources(),
            mPlace.getImgResourceId(), 400, 400);
    
    mPlaceImageViewFull.setImageBitmap(bitmap);
    mPlaceCaption.setText(mPlace.getPlaceNameResId());
    this.getSupportActionBar().setTitle(mPlace.getPlaceNameResId());
    
    mVisitedCheckBox.setChecked(mPlace.isVisited());
    mVisitedCheckBox.setOnCheckedChangeListener(
            new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton view, boolean isChecked) {
            mPlace.setVisited(isChecked);
        }
    });
    
    mConnManager = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
    
    NetworkInfo activeNetwork = mConnManager.getActiveNetworkInfo();
    boolean isConnected = activeNetwork != null && activeNetwork.isConnected();
    
    if (!isConnected) {
        mIndicator.setVisibility(View.INVISIBLE);
        mBackupEmptyView.setText(R.string.empty_placeholder);
    }
}
 
开发者ID:plweegie,项目名称:piast-trail,代码行数:76,代码来源:PlaceDetailsActivity.java

示例15: onCreate

import android.webkit.WebView; //导入方法依赖的package包/类
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_alert__ssend);

    snackaction1 = new View.OnClickListener() {
        @Override
        public void onClick(View v) {

        }
    };

    mToolbar = (Toolbar) findViewById(R.id.toolbar);

    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setElevation(5);
    getSupportActionBar().setTitle("digiPune");


    final String PREFS_NAME = "GeoPreferences";
    final SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);

    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    btn = (FloatingActionButton) findViewById(R.id.button1);
    edtTitle = (EditText) findViewById(R.id.editText2);
    edtMessage = (EditText) findViewById(R.id.editText);

    wb = (WebView) findViewById(R.id.webView3);
    wb.setVisibility(View.GONE);
    wb.getSettings().setJavaScriptEnabled(true);
    wb.getSettings().setAllowFileAccess(true);
    wb.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
    wb.getSettings().setBuiltInZoomControls(true);
    wb.getSettings().setSupportZoom(true);
    wb.setWebViewClient(new WebViewClient());

    wb.setWebChromeClient(new WebChromeClient() {
        public void onProgressChanged(WebView view, int progress) {
            if (progress < 100) {

            }

            if (progress == 100) {
                Snackbar.make(findViewById(android.R.id.content), "Alert Sent", Snackbar.LENGTH_LONG)
                        .setAction("OK", snackaction1)
                        .setActionTextColor(Color.WHITE)
                        .show();

            }
        }
    });

    btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String Title, Message;
            Title = edtTitle.getText().toString();
            Message = edtMessage.getText().toString();
            wb.loadUrl("http://www.skylinelabs.in/Geo/alert.php?user_name="+settings.getString("user_name","")+"&title="+Title+"&message="+Message);

        }
    });



}
 
开发者ID:SkylineLabs,项目名称:FindX,代码行数:68,代码来源:Alert_Send.java


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