Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Get Specific Information From the Internet In Android App
    primarykey
    data
    text
    <p>im pretty new In Android App development, I need some help. Im creating this simple dictionary application that prompts the user to enter a word and after a button press it will take that word to the internet, probably wikipedia.org and return that information to the User. I used XML to develop the app textfield and button. And created a piece of text (ansa) which will be set to whatever the answer is using the OnClickListener, I do not want to set up a webview I just want the text to be set to the dictionary answer. Here's what i have been able to do so far. There is this class to get data from google.</p> <pre><code>public class GetMethod { public String getInternetData() throws Exception{ BufferedReader in = null; String data = null; try{ HttpClient client = new DefaultHttpClient(); URI website = new URI("http://www.google.com"); HttpGet request = new HttpGet(); request.setURI(website); HttpResponse response = client.execute(request); in = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); StringBuffer sb = new StringBuffer(""); String l = ""; String nl = System.getProperty("line.separator"); while((l = in.readLine()) !=null){ sb.append(l + nl); } in.close(); data = sb.toString(); return data; }finally{ if (in !=null){ try{ in.close(); return data; }catch(Exception e){ e.printStackTrace(); } } } } </code></pre> <p>And Another class where the XML is implemented</p> <pre><code>public class Dictionary extends Activity { TextView ansa; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.dictionary); Button Search = (Button) findViewById(R.id.search); ansa = (TextView) findViewById(R.id.ansa); final GetMethod test = new GetMethod(); Search.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub String returned; try { returned = test.getInternetData(); ansa.setText(returned); } catch (Exception e) { ansa.setText("Failed"); // TODO Auto-generated catch block e.printStackTrace(); } } }); } </code></pre> <p>} When it executes I get the whole website's HTML</p> <p>So I need help on how to take the user's word to the wiki website, and get only the text of the ansa, probably parse and store it to some string. Thank You Alot.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload