Note that there are some explanatory texts on larger screens.

plurals
  1. PODownloading a website to a string
    primarykey
    data
    text
    <p>Having done some basic tutorials, I started making my first real android app in eclipse. I want this app to check if the text in an EditText matches the text on a website (this one: <a href="http://www.augustinianum.eu/roosterwijzigingen/14062012.pdf" rel="nofollow">http://www.augustinianum.eu/roosterwijzigingen/14062012.pdf</a> (it contains my school's schedule changes)). I've found out how to make the app check if the text in the EditText matches a string (with the method contains()), so now the only thing I need to do is to download all of the text of that website to a string. But I have no idea how to. Or is there maybe a method which I can check with if a website contains a certain word without downloading the website's text to a string.</p> <p>Thank You!</p> <p>(BTW I'm not English so plz forgive me if I've made some language-related mistakes.)</p> <p>@androider I can't post my code in the comment box so here it is:</p> <pre><code>package me.moop.mytwitter; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; import android.app.Activity; import android.app.ProgressDialog; public class MainActivity extends Activity { Button mBtnCheck; EditText mEtxtGroup; ProgressDialog mProgressDialog; TwitterUser mTwitterUser; TextView mTxtv1; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.nicelayout3); mBtnCheck = (Button) findViewById(R.id.btnCheck); mEtxtGroup = (EditText) findViewById(R.id.etxtGroup); mTxtv1 = (TextView) findViewById(R.id.textView1); } public void checkScheduleChange(View view){ if (view == mBtnCheck){ String group; group = mEtxtGroup.getText().toString(); if (group.length() &gt; 0){ mProgressDialog = new ProgressDialog(this); mProgressDialog.setMessage("Bezig met checken voor roosterwijzigingen..."); mProgressDialog.show(); try { URL url = new URL("http://www.augustinianum.eu/roosterwijzigingen/14062012.pdf"); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); String str; while ((str = in.readLine()) != null){ mProgressDialog.dismiss(); if(str.contains(mEtxtGroup.getText().toString())){ Toast.makeText(this, "U hebt een roosterwijziging.", Toast.LENGTH_LONG).show(); } else{ Toast.makeText(this, "U hebt geen roosterwijzigingen", Toast.LENGTH_LONG).show(); } } in.close(); } catch (MalformedURLException e) { Toast.makeText(this, "Er is een fout opgetreden, probeer opniew.", Toast.LENGTH_LONG).show(); } catch (IOException e) { Toast.makeText(this, "Er is een fout opgetreden, probeer opniew.", Toast.LENGTH_LONG).show(); } } else{ Toast.makeText(this, "Voer een klas in", Toast.LENGTH_LONG).show(); } } } } </code></pre> <p>Here are the button's properties:</p> <pre><code> &lt;Button android:id="@+id/btnCheck" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:clickable="true" android:onClick="checkScheduleChange" android:text="Check" &gt; </code></pre>
    singulars
    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.
 

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