OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.webview_shell; |
| 6 |
| 7 import android.app.Activity; |
| 8 import android.content.Intent; |
| 9 import android.os.Bundle; |
| 10 import android.webkit.WebView; |
| 11 import android.webkit.WebViewClient; |
| 12 |
| 13 /** |
| 14 * This activity is designed for URL browsing testing of WebView. It takes a URL
as an argument, and |
| 15 * displays the page. |
| 16 */ |
| 17 public class WebViewBrowserActivity extends Activity { |
| 18 |
| 19 @Override |
| 20 public void onCreate(Bundle savedInstanceState) { |
| 21 super.onCreate(savedInstanceState); |
| 22 getWindow().setTitle( |
| 23 getResources().getString(R.string.title_activity_browser)); |
| 24 setContentView(R.layout.activity_webview); |
| 25 WebView webView = (WebView) findViewById(R.id.webview); |
| 26 |
| 27 webView.setWebViewClient(new WebViewClient() { |
| 28 @Override |
| 29 public boolean shouldOverrideUrlLoading(WebView webView, String url)
{ |
| 30 return false; |
| 31 } |
| 32 }); |
| 33 |
| 34 String url = getUrlFromIntent(getIntent()); |
| 35 webView.loadUrl(url); |
| 36 } |
| 37 |
| 38 private static String getUrlFromIntent(Intent intent) { |
| 39 return intent != null ? intent.getDataString() : null; |
| 40 } |
| 41 |
| 42 } |
OLD | NEW |