create cron in android app -


i have problem, need make method run every often, problem methods need activity start , not know how need give activity. try create service , work timer problem radico that. leave methods see.

public void push(activity activity,string codigoevento){     sessionmanager manager = new sessionmanager();     folioevento = manager.getvalue(activity,"folioevento");     nombrecliente = manager.getvalue(activity,"nombrecliente");     if(!(folioevento.equals("") || nombrecliente.equals(""))){         connectioninternet cn = new connectioninternet();         if(cn.isnetworkavailable(activity)){         string ids = "";         bdtickets = new ticketsbasedatos(activity, "eventrid", null, 1);         sqlitedatabase db = bdtickets.getwritabledatabase();         cursor c = db.rawquery("select inscripcion_id inscripcion validado=1 , sincronizado = 1 , codigo_usuario =si-1",null);         if (c.movetofirst()) {              {                 ids += c.getstring(0)+",";                 contentvalues valores = new contentvalues();                 valores.put("sincronizado","1");                 string[] args = new string[]{c.getstring(0), codigoevento};                 db.update("inscripcion", valores, "inscripcion_id=? , codigo_evento=?", args);              } while(c.movetonext());         }         db.close();         c.close();         jsonparser jparser = new jsonparser();         jsonobject json = jparser.getjsonfromurl(config.url_base+nombrecliente+"/"+config.url_push+folioevento+"/"+ids);         try {               string status = json.getstring("status");               if(status.equals("1")){                   system.out.println("bien");               }               else{                   system.out.println("mal");               }           } catch (jsonexception e) {             e.printstacktrace();           }         }     } } 

there no lines in code require activity. there many lines require context. activity context. service context. if change activity activity parameter context context, appear code should work using service instead of activity.


Comments

Popular posts from this blog

php - Magento - Deleted Base url key -

javascript - Tooltipster plugin not firing jquery function when button or any click even occur -

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -