如何在用户运行应用程序(如WhatsApp和Line)之前检查并从mysql中获取自动新数据并在Android应用程序中显示,当您连接到Internet时,即使应用程序关闭也会显示新信息?!
答案 0 :(得分:1)
添加启动画面并将此代码放入 主要课程
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet("http://www.someplace.com");
ResponseHandler<String> resHandler = new BasicResponseHandler();
String page = httpClient.execute(httpGet, resHandler);
然后使用jsoup就像这样使用这些类。
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
public class TestClass {
public static void main(String args[]) {
String html = "<p>An <a href='http://example.com/'><b>example</b></a> link.</p>";
Document doc = Jsoup.parse(html);
Element link = doc.select("a").first();
String text = doc.body().text(); // "An example link"
String linkHref = link.attr("href"); // "http://example.com/"
String linkText = link.text(); // "example""
String linkOuterH = link.outerHtml();
// "<a href="http://example.com"><b>example</b></a>" String linkInnerH = link.html();
// "<b>example</b>"
并查看此链接以实施后台服务http://www.vogella.com/tutorials/AndroidServices/article.html