java - Getting Android Alarms Info -


iv'e created several alarms using intent , broadcastreciever , placed them in array of intents. each intent iv'e placed string in intent.putextra("info", string); shown later toast when alarm activated, , gave each different requestcode. when adding multiple alarms, toast shows every other alarms' info well. mainactivity:

intent newalarmintent = new intent(this,alarmreceiver.class);         newalarmintent.putextra("info",edittext.gettext().tostring());         alarmsarray[alarmcounter]=newalarmintent;         alarm.alarmlistsortandsetnext(gamearraylist, alarmarray, this,alarmcounter,alarmsarray[alarmcounter]); 

alarm class:

 public void createnew (context context, long alarmtimeaslong, int counter, intent intent) { pendingintent pendingintent; pendingintent = pendingintent.getbroadcast(context, counter, intent, pendingintent.flag_update_current); alarmmanager manager; manager = (alarmmanager)context.getsystemservice(context.alarm_service); manager.set(alarmmanager.rtc_wakeup, (alarmtimeaslong),pendingintent); toast.maketext(context, "alarm set", toast.length_short).show(); }  public void alarmlistsortandsetnext (arraylist<game> gamearraylist,long[] alarmarray,context context,int alarmcounter, intent intent) {     long systemtimeaslong = system.currenttimemillis();     //sorting long array next alarm     (int i=0;i<10;i++)     {if(i<gamearraylist.size()){             alarmarray[i] = gamearraylist.get(i).getdateandtimeaslong();         }         else alarmarray[i]= 0l;         }     arrays.sort(alarmarray);     //setting next alarm long size     for(int i=0;i<10;i++)     {          if (alarmarray[i]>systemtimeaslong){             createnew(context,alarmarray[i],alarmcounter,intent);             alarmcounter++;}     }} 

alarmreceiver:

public class alarmreceiver extends broadcastreceiver{ @override public void onreceive(context context, intent intent) {     powermanager pm = (powermanager) context.getapplicationcontext().getsystemservice(context.power_service);     powermanager.wakelock wakelock = pm.newwakelock((powermanager.screen_bright_wake_lock | powermanager.full_wake_lock | powermanager.acquire_causes_wakeup), "tag");     wakelock.acquire();     string gameinfo= intent.getstringextra("info");     toast.maketext(context, gameinfo, toast.length_short).show();     mediaplayer mp = mediaplayer.create(context, r.raw.bipbip);     mp.start();     wakelock.release();}} 

question: how can make each intent have it's on "info"/putextra, or other way tell 1 has been activate?

* found issue * had left alarmlistsortandsetnext method supposed manage next alarm. no longer have use method since have created multiple intents. in looping created multiple putextra(); thank you.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -