Re: [android-developers] Re: How to detect if the PendingIntent already exists or not

2016-02-25 Thread TreKing
http://developer.android.com/reference/android/app/PendingIntent.html

A common mistake people make is to create multiple PendingIntent objects
with Intents that only vary in their "extra" contents, expecting to get a
different PendingIntent each time. This does *not* happen. The parts of the
Intent that are used for matching are the same ones defined by
Intent.filterEquals
.
If you use two Intent objects that are equivalent as per Intent.filterEquals
,
then you will get the same PendingIntent for both of them.

On Wed, Feb 24, 2016 at 12:27 AM, Sameer Sharma 
wrote:

> Hi Sir
>
> I have implement the alarm manager in project. I have set the multiple
> alarm at same time. Suppose I have set the five alarms but 4 alarms has
> fired out of 5 or I have set 3 alarms but  2 alarms has fired. Can you give
> me some advice how to solve this problem?
>
> CODE:
>
> private void setAlarm(Calendar targetCal) {
>
> // *change Request code
> RQS_1 = (int) System.currentTimeMillis();
>
>   // Note Declare AlarmReciever in Manifest otherwise Alarm will not
> work
> // 
> Intent intent = new Intent(getBaseContext(), AlarmReceiver.class);
> intent.putExtra("ID", String.valueOf(insert_id));
> intent.putExtra("Time", mTime);
> PendingIntent pendingIntent = PendingIntent.getBroadcast(getBaseContext(),
> RQS_1, intent,0);
> AlarmManager alarmManager = (AlarmManager)
> getSystemService(Context.ALARM_SERVICE);
> // use 24*3600*1000 for repeating after 24//
> alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,targetCal.getTimeInMillis(),
> 24 * 3600 * 1000, pendingIntent);
> //alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP,targetCal.getTimeInMillis(),
> 24 * 3600 * 1000, pendingIntent);
> }
>
> --
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to android-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to android-developers@googlegroups.com.
> Visit this group at https://groups.google.com/group/android-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/android-developers/7dc26ba2-43ed-48de-b092-d4af992cd876%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/CANCScgjzY73%2B9iy55j%3DPhCWRzYPASWhB%3DgtwOaMhiHE8EkraTg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Re: How to detect if the PendingIntent already exists or not

2016-02-23 Thread Sameer Sharma
Hi Sir

I have implement the alarm manager in project. I have set the multiple 
alarm at same time. Suppose I have set the five alarms but 4 alarms has 
fired out of 5 or I have set 3 alarms but  2 alarms has fired. Can you give 
me some advice how to solve this problem?

CODE:

private void setAlarm(Calendar targetCal) {

// *change Request code
RQS_1 = (int) System.currentTimeMillis();

  // Note Declare AlarmReciever in Manifest otherwise Alarm will not 
work
// 
Intent intent = new Intent(getBaseContext(), AlarmReceiver.class);
intent.putExtra("ID", String.valueOf(insert_id));
intent.putExtra("Time", mTime);
PendingIntent pendingIntent = PendingIntent.getBroadcast(getBaseContext(), 
RQS_1, intent,0);
AlarmManager alarmManager = (AlarmManager) 
getSystemService(Context.ALARM_SERVICE);
// use 24*3600*1000 for repeating after 24//
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,targetCal.getTimeInMillis(), 
24 * 3600 * 1000, pendingIntent); 
//alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP,targetCal.getTimeInMillis(),
 
24 * 3600 * 1000, pendingIntent);
}

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/7dc26ba2-43ed-48de-b092-d4af992cd876%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Re: How to detect if the PendingIntent already exists or not

2010-06-22 Thread reda
Hi ,

I've faced this problem and what I did is just creating the intent and
the pendingIntent the same manner I did the first time and now I can
cancel it.

Intent intentToFire = new Intent(Main.ACTION_GET_NEW_EGGS);
PendingIntent alarmPendingIntent =
PendingIntent.getBroadcast(getApplicationContext(), 0, intentToFire,
PendingIntent.FLAG_UPDATE_CURRENT);
alarmPendingIntent.cancel();

It just works for me but I want to hear from other if this will not
fail one day.

++
Reda

On 22 juin, 08:08, Jeruliu jeru@gmail.com wrote:
 Dear all,

 I used AlarmManager to set the pending intent.

 I need to find out the state of the pending intent, in other word, is
 this pending intent working or not.
 Boz i may need to cancel this pending intent, but before canceling it
 i want to make sure it's active.

 But i see no function in AlarmManager can read this status.

 Can anyone advice how to do that?

 Thanks

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to detect if the PendingIntent already exists or not

2010-06-22 Thread reda
Hi ,

I've faced this problem and what I did is just creating the intent and
the pendingIntent the same manner I did the first time and now I can
cancel it.

Intent intentToFire = new Intent(Main.ACTION_GET_NEW_EGGS);
PendingIntent alarmPendingIntent =
PendingIntent.getBroadcast(getApplicationContext(), 0, intentToFire,
PendingIntent.FLAG_UPDATE_CURRENT);
alarmPendingIntent.cancel();

It just works for me but I want to hear from other if this will not
fail one day.

++
Reda

On 22 juin, 08:08, Jeruliu jeru@gmail.com wrote:
 Dear all,

 I used AlarmManager to set the pending intent.

 I need to find out the state of the pending intent, in other word, is
 this pending intent working or not.
 Boz i may need to cancel this pending intent, but before canceling it
 i want to make sure it's active.

 But i see no function in AlarmManager can read this status.

 Can anyone advice how to do that?

 Thanks

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to detect if the PendingIntent already exists or not

2010-06-22 Thread reda
Hi ,

I've faced this problem and what I did is just creating the intent and
the pendingIntent the same manner I did the first time and now I can
cancel it.

Intent intentToFire = new Intent(Main.ACTION_GET_NEW_EGGS);
PendingIntent alarmPendingIntent =
PendingIntent.getBroadcast(getApplicationContext(), 0, intentToFire,
PendingIntent.FLAG_UPDATE_CURRENT);
alarmPendingIntent.cancel();

It just works for me but I want to hear from other if this will not
fail one day.

++
Reda

On 22 juin, 08:08, Jeruliu jeru@gmail.com wrote:
 Dear all,

 I used AlarmManager to set the pending intent.

 I need to find out the state of the pending intent, in other word, is
 this pending intent working or not.
 Boz i may need to cancel this pending intent, but before canceling it
 i want to make sure it's active.

 But i see no function in AlarmManager can read this status.

 Can anyone advice how to do that?

 Thanks

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to detect if the PendingIntent already exists or not

2010-06-22 Thread Jeruliu
Maybe i didn't make myself clearly.

I have no problem to set multiple PendingIntent into the AlarmManager,
my solution is to set a dummy action: intent.setAction(DUMMY);

But the question in this post is: I need to know if the specific
PendingIntent is active or not

I wish to display the PendingIntent status on my screen as active /
inactive


On Jun 22, 2:56 pm, reda reda.a...@gmail.com wrote:
 Hi ,

 I've faced this problem and what I did is just creating the intent and
 the pendingIntent the same manner I did the first time and now I can
 cancel it.

 Intent intentToFire = new Intent(Main.ACTION_GET_NEW_EGGS);
                         PendingIntent alarmPendingIntent =
 PendingIntent.getBroadcast(getApplicationContext(), 0, intentToFire,
 PendingIntent.FLAG_UPDATE_CURRENT);
                         alarmPendingIntent.cancel();

 It just works for me but I want to hear from other if this will not
 fail one day.

 ++
 Reda

 On 22 juin, 08:08, Jeruliu jeru@gmail.com wrote:

  Dear all,

  I used AlarmManager to set the pending intent.

  I need to find out the state of the pending intent, in other word, is
  this pending intent working or not.
  Boz i may need to cancel this pending intent, but before canceling it
  i want to make sure it's active.

  But i see no function in AlarmManager can read this status.

  Can anyone advice how to do that?

  Thanks

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: How to detect if the PendingIntent already exists or not

2010-06-22 Thread Dianne Hackborn
There isn't a way to do this; you will need to keep track of it yourself.

Also I would recommend keeping track of which item you have enabled in your
app, and only setting a single alarm for the next item in time, instead of
having multiple in the alarm manager.  See the alarm clock app for an
example.

On Tue, Jun 22, 2010 at 1:30 AM, Jeruliu jeru@gmail.com wrote:

 Maybe i didn't make myself clearly.

 I have no problem to set multiple PendingIntent into the AlarmManager,
 my solution is to set a dummy action: intent.setAction(DUMMY);

 But the question in this post is: I need to know if the specific
 PendingIntent is active or not

 I wish to display the PendingIntent status on my screen as active /
 inactive


 On Jun 22, 2:56 pm, reda reda.a...@gmail.com wrote:
  Hi ,
 
  I've faced this problem and what I did is just creating the intent and
  the pendingIntent the same manner I did the first time and now I can
  cancel it.
 
  Intent intentToFire = new Intent(Main.ACTION_GET_NEW_EGGS);
  PendingIntent alarmPendingIntent =
  PendingIntent.getBroadcast(getApplicationContext(), 0, intentToFire,
  PendingIntent.FLAG_UPDATE_CURRENT);
  alarmPendingIntent.cancel();
 
  It just works for me but I want to hear from other if this will not
  fail one day.
 
  ++
  Reda
 
  On 22 juin, 08:08, Jeruliu jeru@gmail.com wrote:
 
   Dear all,
 
   I used AlarmManager to set the pending intent.
 
   I need to find out the state of the pending intent, in other word, is
   this pending intent working or not.
   Boz i may need to cancel this pending intent, but before canceling it
   i want to make sure it's active.
 
   But i see no function in AlarmManager can read this status.
 
   Can anyone advice how to do that?
 
   Thanks

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en




-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: How to detect if the PendingIntent already exists or not

2010-06-22 Thread Jeruliu
Thanks for the reply.

1. Ok, i will try too keep track myself, whenever the phone reboot, i
will set all pending intents into the alarm manager, then remember the
active/inactive status.

2. Sometimes i have to create multiple pending intents, for instance i
need to trigger some operation at 8am, 12pm and 3pm everyday. In this
case is it possible to set only a single alarm?

On Jun 22, 4:35 pm, Dianne Hackborn hack...@android.com wrote:
 There isn't a way to do this; you will need to keep track of it yourself.

 Also I would recommend keeping track of which item you have enabled in your
 app, and only setting a single alarm for the next item in time, instead of
 having multiple in the alarm manager.  See the alarm clock app for an
 example.



 On Tue, Jun 22, 2010 at 1:30 AM, Jeruliu jeru@gmail.com wrote:
  Maybe i didn't make myself clearly.

  I have no problem to set multiple PendingIntent into the AlarmManager,
  my solution is to set a dummy action: intent.setAction(DUMMY);

  But the question in this post is: I need to know if the specific
  PendingIntent is active or not

  I wish to display the PendingIntent status on my screen as active /
  inactive

  On Jun 22, 2:56 pm, reda reda.a...@gmail.com wrote:
   Hi ,

   I've faced this problem and what I did is just creating the intent and
   the pendingIntent the same manner I did the first time and now I can
   cancel it.

   Intent intentToFire = new Intent(Main.ACTION_GET_NEW_EGGS);
                           PendingIntent alarmPendingIntent =
   PendingIntent.getBroadcast(getApplicationContext(), 0, intentToFire,
   PendingIntent.FLAG_UPDATE_CURRENT);
                           alarmPendingIntent.cancel();

   It just works for me but I want to hear from other if this will not
   fail one day.

   ++
   Reda

   On 22 juin, 08:08, Jeruliu jeru@gmail.com wrote:

Dear all,

I used AlarmManager to set the pending intent.

I need to find out the state of the pending intent, in other word, is
this pending intent working or not.
Boz i may need to cancel this pending intent, but before canceling it
i want to make sure it's active.

But i see no function in AlarmManager can read this status.

Can anyone advice how to do that?

Thanks

  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

 --
 Dianne Hackborn
 Android framework engineer
 hack...@android.com

 Note: please don't send private questions to me, as I don't have time to
 provide private support, and so won't reply to such e-mails.  All such
 questions should be posted on public forums, where I and others can see and
 answer them.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: How to detect if the PendingIntent already exists or not

2010-06-22 Thread Mark Murphy
On Tue, Jun 22, 2010 at 5:29 AM, Jeruliu jeru@gmail.com wrote:
 2. Sometimes i have to create multiple pending intents, for instance i
 need to trigger some operation at 8am, 12pm and 3pm everyday. In this
 case is it possible to set only a single alarm?

Sure. Set an alarm for 8am. When it goes off, set an alarm for 12pm.
When it goes off, set an alarm for 3pm. When it goes off, set an alarm
for 8am. Etc.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_Android Programming Tutorials_ Version 2.1 Available!

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to detect if the PendingIntent already exists or not

2010-06-22 Thread Jeruliu
Hi Mark,

Good hint, but how do you know a alarm goes off?

BTW, may i know where is your tutorials version 2.1?

On Jun 22, 7:13 pm, Mark Murphy mmur...@commonsware.com wrote:
 On Tue, Jun 22, 2010 at 5:29 AM, Jeruliu jeru@gmail.com wrote:
  2. Sometimes i have to create multiple pending intents, for instance i
  need to trigger some operation at 8am, 12pm and 3pm everyday. In this
  case is it possible to set only a single alarm?

 Sure. Set an alarm for 8am. When it goes off, set an alarm for 12pm.
 When it goes off, set an alarm for 3pm. When it goes off, set an alarm
 for 8am. Etc.

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

 _Android Programming Tutorials_ Version 2.1 Available!

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: How to detect if the PendingIntent already exists or not

2010-06-22 Thread Mark Murphy
On Tue, Jun 22, 2010 at 3:47 PM, Jeruliu jeru@gmail.com wrote:
 Good hint, but how do you know a alarm goes off?

Your PendingIntent is run. Whatever component is started via that
PendingIntent has the responsibility of scheduling the next alarm.

 BTW, may i know where is your tutorials version 2.1?

http://commonsware.com/AndTutorials

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Training...At Your Office: http://commonsware.com/training

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to detect if the PendingIntent already exists or not

2010-06-22 Thread Jeruliu
got it, thanks. You are the man.

On Jun 23, 3:56 am, Mark Murphy mmur...@commonsware.com wrote:
 On Tue, Jun 22, 2010 at 3:47 PM, Jeruliu jeru@gmail.com wrote:
  Good hint, but how do you know a alarm goes off?

 Your PendingIntent is run. Whatever component is started via that
 PendingIntent has the responsibility of scheduling the next alarm.

  BTW, may i know where is your tutorials version 2.1?

 http://commonsware.com/AndTutorials

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

 Android Training...At Your Office:http://commonsware.com/training

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en