我試圖使一個android應用程序顯示我的網站上的最新消息 ,我對這兩件事情有特別的困惑嗎?使用更新創建新聞應用程序安卓android
1.每當 手機自動連接到互聯網時,我怎樣才能從我的網站獲得新聞?
2.我該如何存儲這些信息,然後用它來更新設備?
我發現從谷歌的代碼,我在正確的方向前進?:
public abstract class BaseFeedParser implements FeedParser {
// names of the XML tags
static final String PUB_DATE = "pubDate";
static final String DESCRIPTION = "description";
static final String LINK = "link";
static final String TITLE = "title";
static final String ITEM = "item";
final URL feedUrl;
protected BaseFeedParser(String feedUrl){
try {
this.feedUrl = new URL(feedUrl);
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
protected InputStream getInputStream() {
try {
return feedUrl.openConnection().getInputStream();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}