Fix use of WebView.loadData() to avoid passing invalid encoding

No change in behavior, as invalid encodings have always been ignored.

Bug: 5125738
Change-Id: Ice8ccc2b82e3c5d28169788321dfbbfadb29b392
This commit is contained in:
Steve Block
2011-06-14 21:38:24 +01:00
parent 5430301164
commit aa29f342e5
3 changed files with 13 additions and 14 deletions

View File

@@ -37,7 +37,7 @@ public class Focus1 extends Activity {
WebView webView = (WebView) findViewById(R.id.rssWebView); WebView webView = (WebView) findViewById(R.id.rssWebView);
webView.loadData( webView.loadData(
"<html><body>Can I focus?<br /><a href=\"#\">No I cannot!</a>.</body></html>", "<html><body>Can I focus?<br /><a href=\"#\">No I cannot!</a>.</body></html>",
"text/html", "utf-8"); "text/html", null);
ListView listView = (ListView) findViewById(R.id.rssListView); ListView listView = (ListView) findViewById(R.id.rssListView);
listView.setAdapter(new ArrayAdapter<String>(this, listView.setAdapter(new ArrayAdapter<String>(this,

View File

@@ -35,38 +35,37 @@ public class WebView1 extends Activity {
setContentView(R.layout.webview_1); setContentView(R.layout.webview_1);
final String mimeType = "text/html"; final String mimeType = "text/html";
final String encoding = "utf-8";
WebView wv; WebView wv;
wv = (WebView) findViewById(R.id.wv1); wv = (WebView) findViewById(R.id.wv1);
wv.loadData("<a href='x'>Hello World! - 1</a>", mimeType, encoding); wv.loadData("<a href='x'>Hello World! - 1</a>", mimeType, null);
wv = (WebView) findViewById(R.id.wv2); wv = (WebView) findViewById(R.id.wv2);
wv.loadData("<a href='x'>Hello World! - 2</a>", mimeType, encoding); wv.loadData("<a href='x'>Hello World! - 2</a>", mimeType, null);
wv = (WebView) findViewById(R.id.wv3); wv = (WebView) findViewById(R.id.wv3);
wv.loadData("<a href='x'>Hello World! - 3</a>", mimeType, encoding); wv.loadData("<a href='x'>Hello World! - 3</a>", mimeType, null);
wv = (WebView) findViewById(R.id.wv4); wv = (WebView) findViewById(R.id.wv4);
wv.loadData("<a href='x'>Hello World! - 4</a>", mimeType, encoding); wv.loadData("<a href='x'>Hello World! - 4</a>", mimeType, null);
wv = (WebView) findViewById(R.id.wv5); wv = (WebView) findViewById(R.id.wv5);
wv.loadData("<a href='x'>Hello World! - 5</a>", mimeType, encoding); wv.loadData("<a href='x'>Hello World! - 5</a>", mimeType, null);
wv = (WebView) findViewById(R.id.wv6); wv = (WebView) findViewById(R.id.wv6);
wv.loadData("<a href='x'>Hello World! - 6</a>", mimeType, encoding); wv.loadData("<a href='x'>Hello World! - 6</a>", mimeType, null);
wv = (WebView) findViewById(R.id.wv7); wv = (WebView) findViewById(R.id.wv7);
wv.loadData("<a href='x'>Hello World! - 7</a>", mimeType, encoding); wv.loadData("<a href='x'>Hello World! - 7</a>", mimeType, null);
wv = (WebView) findViewById(R.id.wv8); wv = (WebView) findViewById(R.id.wv8);
wv.loadData("<a href='x'>Hello World! - 8</a>", mimeType, encoding); wv.loadData("<a href='x'>Hello World! - 8</a>", mimeType, null);
wv = (WebView) findViewById(R.id.wv9); wv = (WebView) findViewById(R.id.wv9);
wv.loadData("<a href='x'>Hello World! - 9</a>", mimeType, encoding); wv.loadData("<a href='x'>Hello World! - 9</a>", mimeType, null);
wv = (WebView) findViewById(R.id.wv10); wv = (WebView) findViewById(R.id.wv10);
wv.loadData("<a href='x'>Hello World! - 10</a>", mimeType, encoding); wv.loadData("<a href='x'>Hello World! - 10</a>", mimeType, null);
} }
} }

View File

@@ -95,12 +95,12 @@ public class MyRssReader5 extends Activity implements OnItemSelectedListener {
mLogger.warning("MyRssReader5.onItemSelected() couldn't get the content" + mLogger.warning("MyRssReader5.onItemSelected() couldn't get the content" +
"from the cursor " + e.getMessage()); "from the cursor " + e.getMessage());
} }
mWebView.loadData(content, "text/html", "utf-8"); mWebView.loadData(content, "text/html", null);
} }
//END_INCLUDE(5_4) //END_INCLUDE(5_4)
public void onNothingSelected(AdapterView parent){ public void onNothingSelected(AdapterView parent){
mWebView.loadData("<html><body><p>No selection chosen</p></body></html>", "text/html", "utf-8"); mWebView.loadData("<html><body><p>No selection chosen</p></body></html>", "text/html", null);
} }
// Store our state before we are potentially bumped from memory. // Store our state before we are potentially bumped from memory.