Advertisement
Guest User

Untitled

a guest
Jul 12th, 2014
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.70 KB | None | 0 0
  1. @Override
  2. public void onCreate(Bundle icicle) {
  3. super.onCreate(icicle)
  4. final TextView tv = new TextView(this);
  5. TimerTask scanTask;
  6. final Handler handler = new Handler();
  7. Timer t = new Timer();
  8. scanTask = new TimerTask() {
  9. public void run() {
  10. handler.post(new Runnable() {
  11. public void run() {
  12. URL url = null;
  13. try {
  14. url = new URL("http://www.eurosport.fr/");
  15. } catch (MalformedURLException e3) {
  16.  
  17. e3.printStackTrace();
  18. }
  19.  
  20. /* Get a SAXParser from the SAXPArserFactory. */
  21. SAXParserFactory spf = SAXParserFactory.newInstance();
  22. SAXParser sp;
  23. try {
  24. sp = spf.newSAXParser();
  25. } catch (ParserConfigurationException e2) {
  26.  
  27. e2.printStackTrace();
  28. } catch (SAXException e2) {
  29.  
  30. e2.printStackTrace();
  31. }
  32.  
  33. /* Get the XMLReader of the SAXParser we created. */
  34. XMLReader xr = null;
  35. try {
  36. sp = spf.newSAXParser();
  37. xr = sp.getXMLReader();
  38. } catch (SAXException e1) {
  39.  
  40. e1.printStackTrace();
  41. } catch (ParserConfigurationException e) {
  42.  
  43. e.printStackTrace();
  44. }
  45. /* Create a new ContentHandler and apply it to the XML-Reader*/
  46. ExampleHandler myExampleHandler = new ExampleHandler();
  47. try {
  48. sp = spf.newSAXParser();
  49. } catch (ParserConfigurationException e1) {
  50. // TODO Auto-generated catch block
  51. e1.printStackTrace();
  52. } catch (SAXException e1) {
  53. // TODO Auto-generated catch block
  54. e1.printStackTrace();
  55. }
  56. xr.setContentHandler(myExampleHandler);
  57.  
  58. /* Parse the xml-data from our URL. */
  59. try {
  60. xr.parse(new InputSource(url.openStream()));
  61. } catch (IOException e) {
  62.  
  63. e.printStackTrace();
  64. } catch (SAXException e) {
  65.  
  66. e.printStackTrace();
  67. }
  68. /* Parsing has finished. */
  69.  
  70. /* Our ExampleHandler now provides the parsed data to us. */
  71. ParsedExampleDataSet parsedExampleDataSet =
  72. myExampleHandler.getParsedData();
  73.  
  74. System.out.println(parsedExampleDataSet.toString());
  75.  
  76. tv.setText(parsedExampleDataSet.toString());
  77.  
  78.  
  79. Context context = this.getBaseContext();
  80.  
  81. // I dont understand why inside the runnable getBaseContext() does not exist ???
  82.  
  83. Bitmap mBitmap = BitmapFactory.decodeResource(getResources(),
  84. R.raw.nature1)
  85. context.setWallpaper(mBitmap);
  86.  
  87.  
  88. }
  89.  
  90.  
  91. });
  92.  
  93. } };
  94. // I want to retrieve ParsedExampleDataSEt here in order to use it is it Possible ????
  95.  
  96.  
  97.  
  98. this.setContentView(tv);
  99.  
  100.  
  101.  
  102. long temps=1*15*1000;
  103.  
  104. t.scheduleAtFixedRate(scanTask, 300,temps );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement