Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class AsyncLoadXMLFeed extends AsyncTask<Void, Void, Void> {
- public AsyncLoadXMLFeed() {
- }
- @Override
- protected Void doInBackground(Void... params) {
- //Obtem o feed
- DOMParser myParser = new DOMParser();
- feed = myParser.parseXml(RSSFEEDURL);
- if(feed != null && feed.getItemCount() > 0)
- WriteFeed(feed);
- return null;
- }
- @Override
- protected void onPostExecute(Void result) {
- super.onPostExecute(result);
- startLisActivity(feed);
- }
- }
- private void WriteFeed(RSSFeed data) {
- FileOutputStream fOut = null;
- ObjectOutputStream osw = null;
- try {
- fOut = openFileOutput(fileName, MODE_PRIVATE);
- osw = new ObjectOutputStream(fOut);
- osw.writeObject(data);
- osw.flush();
- } catch (Exception e) {
- e.printStackTrace();
- }
- finally{
- try {
- fOut.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
Add Comment
Please, Sign In to add comment