Re: [android-developers] Re: Setting multiple RTC_WAKEUP alarms from a single app

2011-01-15 Thread Kostya Vasilyev
2011/1/15 kl4232 klavin4...@yahoo.com

 Thank you for this. I accidently posted my question before I was
 finished composing it.


That's what I figured



 So having a unique action (=feature name) for the intent inside the
 pending intent isn't enough.


Distinict action strings would work, but I don't see that in your code.


 I did see, when I did adb ahell dumpsys alarm and I know I had 2
 alarms set, then there was only one RTC_WAKEUP entry for my app, and
 not 2 as I would have expected.
 I'll try putting in a unique request code and see if that solves the
 problem.

 Thanks

 On Jan 15, 10:00 am, Kostya Vasilyev kmans...@gmail.com wrote:
  Alarms are keyed on PendingIntents, there can be only one for a given
  pending intent. This is so you can update settings for an already-set
 alarm.
 
  There are rules for when PendingIntents are considered the same intent,
 or
  different ones. Using the same Java object certainly means it's the same
  intent though.
 
  What you can do is use a request code with PendingIntent.getBroadcast
 that's
  unique for each alarm you want to set - three alarms, three request
 codes,
  three unique PendingIntents.
 
  -- Kostya
 
  2011/1/15 kl4232 klavin4...@yahoo.com
 
 
 
   I have an app which I want to have 3 wake-up alarms to schedule 3
   features of the app.
   They are all set the same way.
 
   m_intentName = com.mypackage.+ FeatureName;
   m_alarmIntent = new Intent(m_intentName);
   m_alarmPendingIntent = PendingIntent.getBroadcast(this, 0,
   m_alarmIntent, 0);
 
   When I want to set the alarm I do this...
m_alarmMgr.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() +
   nMinutes * 60 * 1000, m_alarmPendingIntent);
 
   Then in my broadcast receiver...
   public class FeatureReceiver extends BroadcastReceiver {
   public void onReceive(Context context, Intent intent) {
  if (intent.getAction().compareTo(m_intentName)
 == 0)
   {
 
   --
   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
 android-developers%2Bunsubs­cr...@googlegroups.com
   For more options, visit this group at
  http://groups.google.com/group/android-developers?hl=en- Hide quoted
 text -
 
  - Show quoted text -

 --
 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


-- 
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: Setting multiple RTC_WAKEUP alarms from a single app

2011-01-15 Thread Kostya Vasilyev
This means that the request code does not have any special meaning to
Android (unlike flags, the last paramter).

You can easily check this with a simple test:

- Create an Intent from an action string;
- Call PendingIntent.getBroadcast twice with 0 for request code, log the
results;
- Repeat with different request codes, log the results.

You should see something like:

android.os.BinderProxy@44f8e3d0}
android.os.BinderProxy@44f8e3d0}
android.os.BinderProxy@44f8e3d0}
android.os.BinderProxy@44f8f6b8}
android.os.BinderProxy@44f8fc88}
android.os.BinderProxy@44f90258}

The first three are the same (all created with requestCode == 0), the next
three are unique.

-- Kostya

2011/1/15 kl4232 klavin4...@yahoo.com

 Although the docs for pendingIntent.getBroadcast state that...

 requestCode  Private request code for the sender (currently not
 used).

 On Jan 15, 10:07 am, kl4232 klavin4...@yahoo.com wrote:
  Thank you for this. I accidently posted my question before I was
  finished composing it.
 
  So having a unique action (=feature name) for the intent inside the
  pending intent isn't enough.
  I did see, when I did adb ahell dumpsys alarm and I know I had 2
  alarms set, then there was only one RTC_WAKEUP entry for my app, and
  not 2 as I would have expected.
  I'll try putting in a unique request code and see if that solves the
  problem.
 
  Thanks
 
  On Jan 15, 10:00 am, Kostya Vasilyev kmans...@gmail.com wrote:
 
 
 
   Alarms are keyed on PendingIntents, there can be only one for a given
   pending intent. This is so you can update settings for an already-set
 alarm.
 
   There are rules for when PendingIntents are considered the same intent,
 or
   different ones. Using the same Java object certainly means it's the
 same
   intent though.
 
   What you can do is use a request code with PendingIntent.getBroadcast
 that's
   unique for each alarm you want to set - three alarms, three request
 codes,
   three unique PendingIntents.
 
   -- Kostya
 
   2011/1/15 kl4232 klavin4...@yahoo.com
 
I have an app which I want to have 3 wake-up alarms to schedule 3
features of the app.
They are all set the same way.
 
m_intentName = com.mypackage.+ FeatureName;
m_alarmIntent = new Intent(m_intentName);
m_alarmPendingIntent = PendingIntent.getBroadcast(this, 0,
m_alarmIntent, 0);
 
When I want to set the alarm I do this...
 m_alarmMgr.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() +
nMinutes * 60 * 1000, m_alarmPendingIntent);
 
Then in my broadcast receiver...
public class FeatureReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
   if (intent.getAction().compareTo(m_intentName)
 == 0)
{
 
--
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
 android-developers%2Bunsubs­­cr...@googlegroups.com
For more options, visit this group at
   http://groups.google.com/group/android-developers?hl=en-Hide quoted
 text -
 
   - Show quoted text -- Hide quoted text -
 
  - Show quoted text -

 --
 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


-- 
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