android - Using intents inside Service -
can use intent inside service? should put in "??????"? need call pedingintent alarm inside service.-
example.
public class calcularhorasservice extends service { public int horar; public int minr; private pendingintent pdintautomatico; @override public int onstartcommand( intent intent, int flags, int startid ) { // line key android.os.debug.waitfordebugger(); log.v( "servicio", "entro al servicio" ); getcalcularhorasalida(); setalarma(); // return return super.onstartcommand( intent, flags, startid ); } /** * set alarm */ private void setalarma() { intent intsincroauto = new intent( ????, alarmaactivarbroadauto.class ); pdintautomatico = pendingintent.getbroadcast( ????, 0, intsincroauto, 0); } }
the constructor of intent require context first params, can put this because want create intent inside of service class. service class such contextthemewrapper (which extended activity) extends contextwrapper extends context.
so code can looks like:
intent intsincroauto = new intent( this, alarmaactivarbroadauto.class ); pdintautomatico = pendingintent.getbroadcast( this, 0, intsincroauto, 0);
Comments
Post a Comment