android - Apparently my Intent does not get delivered -
i have application needs start , stop activities.
so far ok starting activity.
the problem comes when try stop activity.
this alarmmanager broadcasts intent close activity:
intent ftue = new intent(ctxt, videoactivty.class); ftue.putextra("finish", true); pendingintent pftue = pendingintent.getbroadcast(ctxt, 0, ftue, 0); calendar calset4 = calendar.getinstance(); calset4.set(calendar.month, c.get(calendar.month)); calset4.set(calendar.year, c.get(calendar.year)); calset4.set(calendar.day_of_week, 3); calset4.set(calendar.hour_of_day, hftue); calset4.set(calendar.minute, mftue); calset4.set(calendar.second, 0); calset4.set(calendar.millisecond, 0); //calset.settimezone(timezone.gettimezone("utc")); mgr.setrepeating(alarmmanager.rtc_wakeup, calset4.gettimeinmillis(), 7 * 24 * 60 * 60 * 1000, pftue);
and in activty have implemented broadcastreceiver should shut down activty.
but without success...
@override public void onresume() { super.onresume(); intentfilter f=new intentfilter(); registerreceiver(receiver, f); } @override public void onpause() { unregisterreceiver(receiver); super.onpause(); } broadcastreceiver receiver=new broadcastreceiver() { public void onreceive(context context, intent intent) { log.e("","intento ricevuto"); if(intent.getbooleanextra("finish",false))finish(); } };
let me make comment answer , expound on it.
if use empty intentfilter
, activity won't ever receive intents broadcasted it. however, if broadcast intent specially reference type of broadcastreceiver, work.
so if defined class myreceiver extends broadcastreceiver
inside videoactivity
, formed broadcast intent new intent(context, videoactivity.myreceiver.class)
would delivered.
hope makes sense.
Comments
Post a Comment