Search in sources :

Example 16 with WebView

use of android.webkit.WebView in project remusic by aa112901.

the class TopFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_top, container, false);
    webView = (WebView) view.findViewById(R.id.webview);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setUserAgentString("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36");
    webView.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            // 根据传入的参数再去加载新的网页
            view.loadUrl(url);
            // 表示当前WebView可以处理打开新网页的请求,不用借助系统浏览器
            return true;
        }
    });
    webView.loadUrl("http://music.163.com/#/discover/toplist?id=19723756");
    return view;
}
Also used : WebView(android.webkit.WebView) View(android.view.View) WebView(android.webkit.WebView) WebViewClient(android.webkit.WebViewClient)

Example 17 with WebView

use of android.webkit.WebView in project android-test-demo by abdyer.

the class WebViewActivity method loadUrl.

private void loadUrl() {
    String url = getIntent().getStringExtra(EXTRA_URL);
    webview.setWebViewClient(new WebViewClient() {

        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return false;
        }
    });
    webview.loadUrl(url);
}
Also used : WebView(android.webkit.WebView) WebViewClient(android.webkit.WebViewClient)

Example 18 with WebView

use of android.webkit.WebView in project FinestWebView-Android by TheFinestArtist.

the class FinestWebViewActivity method bindViews.

protected void bindViews() {
    coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinatorLayout);
    appBar = (AppBarLayout) findViewById(R.id.appBar);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbarLayout = (RelativeLayout) findViewById(R.id.toolbarLayout);
    title = (TextView) findViewById(R.id.title);
    urlTv = (TextView) findViewById(R.id.url);
    close = (AppCompatImageButton) findViewById(R.id.close);
    back = (AppCompatImageButton) findViewById(R.id.back);
    forward = (AppCompatImageButton) findViewById(R.id.forward);
    more = (AppCompatImageButton) findViewById(R.id.more);
    close.setOnClickListener(this);
    back.setOnClickListener(this);
    forward.setOnClickListener(this);
    more.setOnClickListener(this);
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
    gradient = findViewById(R.id.gradient);
    divider = findViewById(R.id.divider);
    progressBar = (ProgressBar) findViewById(R.id.progressBar);
    menuLayout = (RelativeLayout) findViewById(R.id.menuLayout);
    shadowLayout = (ShadowLayout) findViewById(R.id.shadowLayout);
    menuBackground = (LinearLayout) findViewById(R.id.menuBackground);
    menuRefresh = (LinearLayout) findViewById(R.id.menuRefresh);
    menuRefreshTv = (TextView) findViewById(R.id.menuRefreshTv);
    menuFind = (LinearLayout) findViewById(R.id.menuFind);
    menuFindTv = (TextView) findViewById(R.id.menuFindTv);
    menuShareVia = (LinearLayout) findViewById(R.id.menuShareVia);
    menuShareViaTv = (TextView) findViewById(R.id.menuShareViaTv);
    menuCopyLink = (LinearLayout) findViewById(R.id.menuCopyLink);
    menuCopyLinkTv = (TextView) findViewById(R.id.menuCopyLinkTv);
    menuOpenWith = (LinearLayout) findViewById(R.id.menuOpenWith);
    menuOpenWithTv = (TextView) findViewById(R.id.menuOpenWithTv);
    webLayout = (FrameLayout) findViewById(R.id.webLayout);
    webView = new WebView(this);
    webLayout.addView(webView);
}
Also used : WebView(android.webkit.WebView)

Example 19 with WebView

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

the class NetworkActivity method showErrorPage.

// Displays an error if the app is unable to load content.
private void showErrorPage() {
    setContentView(R.layout.main);
    // The specified network connection is not available. Displays error message.
    WebView myWebView = (WebView) findViewById(R.id.webview);
    myWebView.loadData(getResources().getString(R.string.connection_error), "text/html", null);
}
Also used : WebView(android.webkit.WebView)

Example 20 with WebView

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

the class PowerTestActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.v(LOGTAG, "onCreate, inst=" + Integer.toHexString(hashCode()));
    LinearLayout contentView = new LinearLayout(this);
    contentView.setOrientation(LinearLayout.VERTICAL);
    setContentView(contentView);
    setTitle("Idle");
    webView = new WebView(this);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
    webView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
    webViewClient = new SimpleWebViewClient();
    chromeClient = new SimpleChromeClient();
    webView.setWebViewClient(webViewClient);
    webView.setWebChromeClient(chromeClient);
    contentView.addView(webView, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0.0f));
    handler = new Handler() {

        @Override
        public void handleMessage(Message msg) {
            switch(msg.what) {
                case MSG_TIMEOUT:
                    handleTimeout();
                    return;
                case MSG_NAVIGATE:
                    manualDelay = msg.arg2;
                    navigate(msg.getData().getString(MSG_NAV_URL), msg.arg1);
                    logTime = msg.getData().getBoolean(MSG_NAV_LOGTIME);
                    return;
            }
        }
    };
    pageDoneLock = new Object();
}
Also used : LayoutParams(android.widget.LinearLayout.LayoutParams) Message(android.os.Message) Handler(android.os.Handler) WebView(android.webkit.WebView) LinearLayout(android.widget.LinearLayout)

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