android - Notify me if weather is gonna rain -


hi want ask, how able notify phone if gonna rain when send request current weather request should run on background , if gonna rain notify.

can give hints or tutorial me able send request through service , notify me if gonna rain please share ideas

cause need , thank you.

i have done class requesting current location , use openweathermap api me current weather.

package com.example.autoapp;  import java.io.bufferedreader; import java.io.inputstream; import java.io.inputstreamreader;  import org.apache.http.httpentity; import org.apache.http.httpresponse; import org.apache.http.statusline; import org.apache.http.client.httpclient; import org.apache.http.client.methods.httpget; import org.apache.http.impl.client.defaulthttpclient; import org.json.jsonobject;  public class weatherjsonparser {      public weatherjsonparser()      {      }      public jsonobject getweatherfromurl(string url)     {         string holder= null;         jsonobject jobj=null;         try         {             httpclient client= new defaulthttpclient();             httpget get= new httpget(url);             httpresponse response= client.execute(get);             statusline sline= response.getstatusline();             int status= sline.getstatuscode();               if(status==200)              {                 httpentity content= response.getentity();                 inputstream istream= content.getcontent();                 stringbuilder cbuilder= new stringbuilder();                 bufferedreader breader= new bufferedreader(new inputstreamreader(istream));                 string cline=null;                 while((cline=breader.readline())!= null)                 {                     cbuilder.append(cline);                 }                 istream.close();                 holder= cbuilder.tostring();                 jobj= new jsonobject(holder);                   return jobj;             }          }          catch(exception e)         {             e.printstacktrace();         }         return null;     }   } 

    private final string url = "http://api.worldweatheronline.com/free/v1/weather.ashx?key=***your api key*****&q=00.00,00.00&cc=no&date=2010-04-23&format=xml";         private static final string key_song = "weather"; // parent node          // public variable         public static final string key_temperature_maximum = "tempmaxc";         public static final string key_temperature_minimum = "tempminc";         public static final string key_weather_description = "weatherdesc";         public static final string key_precipitation = "precipmm";         public static final string key_thumb_url = "weathericonurl";     private  arraylist<hashmap<string, string>> alist =null;  @override     protected void oncreate(bundle savedinstancestate) { new longoperation().execute(""); }    private class longoperation extends asynctask<string, void, string> {           @override          protected string doinbackground(string... params) {                  alist = new arraylist<hashmap<string, string>>();               xmlparser parser = new xmlparser();               string xml = parser.getxmlfromurl(url); // getting xml url                document doc = parser.getdomelement(xml);               nodelist nl = doc.getelementsbytagname(key_song);               // looping through song nodes <song>               try {                 (int = 0; < nl.getlength(); i++) {                     // creating new hashmap                     map = new hashmap<string, string>();                      element e = (element) nl.item(i);                      // adding each child node hashmap key => value                     map.put(key_temperature_maximum, parser.getvalue(e, key_temperature_maximum));                      map.put(key_temperature_minimum, parser.getvalue(e, key_temperature_minimum));                      map.put(key_weather_description, parser.getvalue(e, key_weather_description).trim());                      map.put(key_precipitation, parser.getvalue(e, key_precipitation));                      map.put(key_thumb_url, parser.getvalue(e, key_thumb_url));                      // adding hashlist arraylist                     alist.add(map);                  }             } catch (nullpointerexception e) {                 // todo auto-generated catch block                 e.printstacktrace();             }               adapter = new lazyadapterforweather(weatherreportactivity.this, alist, 0);               return "executed";           }                 @override          protected void onpostexecute(string result) {            if(mprogressdialog.isshowing()){              mprogressdialog.dismiss();          }              list.setadapter(adapter);           }           @override          protected void onpreexecute() {          showloading();          }           @override          protected void onprogressupdate(void... values) {           }       } 

see in way can weather report . running same thing in service @ regular interval need merge 2 code


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -