Search in sources :

Example 36 with WebView

use of android.webkit.WebView in project DroidPlugin by DroidPluginTeam.

the class WebViewTestActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_web_view_test);
    mWebView = (WebView) findViewById(R.id.webview);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return true;
        }
    });
    mWebView.loadUrl("http://www.baidu.com");
}
Also used : WebView(android.webkit.WebView) WebViewClient(android.webkit.WebViewClient)

Example 37 with WebView

use of android.webkit.WebView in project bilibili-android-client by HotBitmapGG.

the class BrowserActivity method setupWebView.

@SuppressLint("SetJavaScriptEnabled")
private void setupWebView() {
    progressBar.spin();
    final WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    webSettings.setDomStorageEnabled(true);
    webSettings.setGeolocationEnabled(true);
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);
    mWebView.getSettings().setBlockNetworkImage(true);
    mWebView.setWebViewClient(webViewClient);
    mWebView.requestFocus(View.FOCUS_DOWN);
    mWebView.getSettings().setDefaultTextEncodingName("UTF-8");
    mWebView.setWebChromeClient(new WebChromeClient() {

        @Override
        public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {
            AlertDialog.Builder b2 = new AlertDialog.Builder(BrowserActivity.this).setTitle(R.string.app_name).setMessage(message).setPositiveButton("确定", (dialog, which) -> result.confirm());
            b2.setCancelable(false);
            b2.create();
            b2.show();
            return true;
        }
    });
    mWebView.loadUrl(url);
}
Also used : JsResult(android.webkit.JsResult) ConstantUtil(com.hotbitmapgg.bilibili.utils.ConstantUtil) Bundle(android.os.Bundle) JsResult(android.webkit.JsResult) Uri(android.net.Uri) Intent(android.content.Intent) RxBaseActivity(com.hotbitmapgg.bilibili.base.RxBaseActivity) MenuItem(android.view.MenuItem) BindView(butterknife.BindView) SuppressLint(android.annotation.SuppressLint) R(com.hotbitmapgg.ohmybilibili.R) WebSettings(android.webkit.WebSettings) WebResourceRequest(android.webkit.WebResourceRequest) Handler(android.os.Handler) Menu(android.view.Menu) WebViewClient(android.webkit.WebViewClient) View(android.view.View) WebView(android.webkit.WebView) ActionBar(android.support.v7.app.ActionBar) WebChromeClient(android.webkit.WebChromeClient) TextUtils(android.text.TextUtils) AlertDialog(android.app.AlertDialog) WebResourceError(android.webkit.WebResourceError) CircleProgressView(com.hotbitmapgg.bilibili.widget.CircleProgressView) Toolbar(android.support.v7.widget.Toolbar) Bitmap(android.graphics.Bitmap) ToastUtil(com.hotbitmapgg.bilibili.utils.ToastUtil) ClipboardUtil(com.hotbitmapgg.bilibili.utils.ClipboardUtil) Activity(android.app.Activity) WebSettings(android.webkit.WebSettings) WebChromeClient(android.webkit.WebChromeClient) WebView(android.webkit.WebView) SuppressLint(android.annotation.SuppressLint)

Example 38 with WebView

use of android.webkit.WebView in project OneSignal-Android-SDK by OneSignal.

the class GreenActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_green);
    String openURL = getIntent().getStringExtra("openURL");
    final TextView textView = (TextView) findViewById(R.id.debug_view);
    textView.setText("URL from additionalData: " + openURL);
    Button onBackButton = (Button) (findViewById(R.id.back_button));
    onBackButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(getApplicationContext(), MainActivity.class);
            startActivity(intent);
        }
    });
    WebView webView = (WebView) (findViewById(R.id.webview));
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setWebViewClient(new WebViewClient());
    if (openURL == null) {
        webView.loadUrl("https://google.com");
    } else {
        webView.loadUrl(openURL);
    }
}
Also used : Button(android.widget.Button) TextView(android.widget.TextView) Intent(android.content.Intent) WebView(android.webkit.WebView) TextView(android.widget.TextView) View(android.view.View) WebView(android.webkit.WebView) WebViewClient(android.webkit.WebViewClient)

Example 39 with WebView

use of android.webkit.WebView in project Rashr by DsLNeXuS.

the class SettingsFragment method showChangelog.

public static void showChangelog(Context AppContext) {
    AlertDialog.Builder dialog = new AlertDialog.Builder(AppContext);
    dialog.setTitle(R.string.changelog);
    WebView changes = new WebView(AppContext);
    changes.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    changes.setWebViewClient(new WebViewClient());
    changes.loadUrl(Const.CHANGELOG_URL);
    changes.clearCache(true);
    dialog.setView(changes);
    dialog.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) WebView(android.webkit.WebView) WebViewClient(android.webkit.WebViewClient)

Example 40 with WebView

use of android.webkit.WebView in project android_frameworks_base by DirtyUnicorns.

the class ScrollableWebViewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    WebView webView = new WebView(this);
    webView.loadData(sHtml, "text/html", null);
    webView.setVerticalScrollBarEnabled(true);
    setContentView(webView);
}
Also used : WebView(android.webkit.WebView)

Aggregations

WebView (android.webkit.WebView)594 WebViewClient (android.webkit.WebViewClient)214 View (android.view.View)176 WebSettings (android.webkit.WebSettings)103 Intent (android.content.Intent)87 SuppressLint (android.annotation.SuppressLint)79 WebChromeClient (android.webkit.WebChromeClient)77 TextView (android.widget.TextView)61 Bitmap (android.graphics.Bitmap)55 LinearLayout (android.widget.LinearLayout)39 DialogInterface (android.content.DialogInterface)36 ImageView (android.widget.ImageView)35 WebResourceRequest (android.webkit.WebResourceRequest)32 Uri (android.net.Uri)31 Test (org.junit.Test)27 Bundle (android.os.Bundle)26 AlertDialog (android.app.AlertDialog)24 Activity (android.app.Activity)22 Handler (android.os.Handler)20 IOException (java.io.IOException)20