Guest User

Untitled

a guest
Jun 19th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. public class AsyncLoadXMLFeed extends AsyncTask<Void, Void, Void> {
  2.  
  3. public AsyncLoadXMLFeed() {
  4.  
  5. }
  6.  
  7.  
  8. @Override
  9. protected Void doInBackground(Void... params) {
  10.  
  11. //Obtem o feed
  12. DOMParser myParser = new DOMParser();
  13. feed = myParser.parseXml(RSSFEEDURL);
  14. if(feed != null && feed.getItemCount() > 0)
  15. WriteFeed(feed);
  16. return null;
  17. }
  18.  
  19. @Override
  20. protected void onPostExecute(Void result) {
  21. super.onPostExecute(result);
  22.  
  23. startLisActivity(feed);
  24. }
  25.  
  26. }
  27.  
  28. private void WriteFeed(RSSFeed data) {
  29.  
  30. FileOutputStream fOut = null;
  31. ObjectOutputStream osw = null;
  32.  
  33. try {
  34. fOut = openFileOutput(fileName, MODE_PRIVATE);
  35. osw = new ObjectOutputStream(fOut);
  36. osw.writeObject(data);
  37. osw.flush();
  38. } catch (Exception e) {
  39. e.printStackTrace();
  40. }
  41. finally{
  42. try {
  43. fOut.close();
  44. } catch (IOException e) {
  45. e.printStackTrace();
  46. }
  47. }
  48.  
  49. }
Add Comment
Please, Sign In to add comment