im trying to create an application where a page has its text created automatically by reading off a website?
I understand an array would be used and string formatting, i am ok with android programming but not an expert lol.
I had tried using a set of coding found on this website but i think this is for only reading off a text file online:
private TextView outtext;
private String HTML;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
/*FROM HERE*/
outtext= (TextView) findViewById(R.id.textview1); //change id if needed!!!
try {
getHTML();
} catch (Exception e) {
e.printStackTrace();
}
outtext.setText("" + HTML);
/*TO HERE*/
}
private void getHTML() throws ClientProtocolException, IOException
{
HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpGet httpGet = new HttpGet("http://www.bbc.co.uk/news/"); //URL!
HttpResponse response = httpClient.execute(httpGet, localContext);
String result = "";
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = null;
while ((line = reader.readLine()) != null) {
result += line + "\n";
HTML = result;
}
}
}
I tried using bbc.co.uk/news/ as an example. The text view on my app returned 'null'.
Hope someone can help me out, thanks in advance.