Reputation: 1642
How can check and get automatic new data from mysql and show in android app before user run application like WhatsApp and Line,when you connect to the Internet show new info even when the app is closed ?!
Upvotes: 0
Views: 47
Reputation: 86
Add a splashscreen and put this code in Main class
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet("http://www.someplace.com");
ResponseHandler<String> resHandler = new BasicResponseHandler();
String page = httpClient.execute(httpGet, resHandler);
Then using jsoup uses these classes like so.
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>"
And check this link to implement background service http://www.vogella.com/tutorials/AndroidServices/article.html
Upvotes: 1