Created
July 11, 2014 15:17
-
-
Save kakawka/067595c290a72ad782ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends Activity { | |
/** Called when the activity is first created. */ | |
Button butTest; | |
TextView textView; | |
String title; | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
butTest = (Button)findViewById(R.id.button); | |
textView = (TextView)findViewById(R.id.textView); | |
new MyParser().execute("http://beastinvest.su/"); | |
butTest.setOnClickListener(butOncl); | |
} | |
private View.OnClickListener butOncl = new View.OnClickListener() { | |
public void onClick(View v) { | |
onPostExecute(title); | |
} | |
}; | |
public class MyParser extends AsyncTask<String, Void, String> { | |
@Override | |
protected String doInBackground(String... links) { | |
Document doc = null; | |
try { | |
doc = Jsoup.connect(links[0]).get(); | |
title = doc.title(); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
return null; | |
} | |
} | |
public void onPostExecute(String result) { | |
textView.setText(title); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment