Alarm manager for multiple pending intent are not working.

by nomi » Mon, 16 Aug 2010 15:49:34 GMT


Sponsored Links
 Hi all,

In my application i have created pending intent which calls another
activity (after 20mins of alarm off) with the help of alarm manger. It
should happen each time for each new pending intent or when I call
that activity.
But when i create one pending intent and after few mins again create
new pending intent ,then the last one overlap the other previous
pending intents and start specified activity only for ones for the
last pending intent.

I want  that each time i create any pending intent it should start
specified activity after 20 mins of it's alarm off time.How it can be
done ?
here is my code:--


Intent intent = new Intent(getApplicationContext(),AlarmCall.class);

                                        intent.putExtra("PolicyNo3",policyNo2);

                                        intent.putExtra("BarcodeNo",barcode_no);
                                        
Constants.pendingResultList.put(policyNo2, barcode_no);
        
System.out.println(Constants.pendingResultList.containsKey(policyNo2));

                                        PendingIntent pendingIntent =
PendingIntent.getBroadcast(getApplicationContext(),
0,intent,PendingIntent.FLAG_UPDATE_CURRENT);
                                        AlarmManager alarmManager = 
(AlarmManager)
getSystemService(ALARM_SERVICE);

                                long timedely = System.currentTimeMillis() + 
(20*60*1000);
        
alarmManager.set(AlarmManager.RTC_WAKEUP,timedely,
                                            pendingIntent);









////// Below is the code of ALarmCall.class






manger = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
                 Notification notification = new
Notification(R.drawable.icon,"Please upload
result",System.currentTimeMillis());
                 Intent startActivity1 = new Intent();
                        startActivity1.setClass(context, UploadTest.class);
                        startActivity1.setAction(UploadTest.class.getName());
                        startActivity1.putExtra( "PolicyNo4",policyNo3);
                        startActivity1.putExtra("BarcodeNo1",barcodeNo);
                        startActivity1.addFlags(
                        Intent.FLAG_ACTIVITY_NEW_TASK
                        | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);

                 PendingIntent contentIntent = 
PendingIntent.getActivity(context,
0,startActivity1    ,Intent.FLAG_ACTIVITY_NEW_TASK);
                 notification.setLatestEventInfo(context, "HIV 
Pharmacy","Result of
Id- "+policyNo3,contentIntent);
                 notification.flags = Notification.FLAG_ONLY_ALERT_ONCE |
Notification.FLAG_SHOW_LIGHTS;
                 notification.ledARGB = Color.GREEN;
                 notification.ledOnMS = 1000;
                 notification.ledOffMS = 500;
                 notification.defaults = Notification.DEFAULT_SOUND |
Notification.DEFAULT_VIBRATE;
                 manger.notify(32, notification);
                 context.startActivity(startActivity1);




 Thanks to all.

--



Alarm manager for multiple pending intent are not working.

by skink » Mon, 16 Aug 2010 16:21:40 GMT


 omi wrote:

each time you call getBroadcast|getActivity use unique requestCode

pskink

--


Sponsored Links


Alarm manager for multiple pending intent are not working.

by Kostya Vasilyev » Mon, 16 Aug 2010 17:44:46 GMT


 tt> Setting an alarm cancels any previous alarms that have the same intent 
as the new one.


In your code, the old and new intents only differ by their extras, which
are not considered (I believe).


What you could do is calculate the next point in time when an alarm is
needed, set one alarm, and when it goes off, figure out which of the
possible actions you need to perform.


-- Kostya

16.08.2010 11:49, nomi :

Hi all,

In my application i have created pending intent which calls another
activity (after 20mins of alarm off) with the help of alarm manger. It
should happen each time for each new pending intent or when I call
that activity.
But when i create one pending intent and after few mins again create
new pending intent ,then the last one overlap the other previous
pending intents and start specified activity only for ones for the
last pending intent.

I want that each time i create any pending intent it should start
specified activity after 20 mins of it's alarm off time.How it can be
done ?
here is my code:--


Intent intent = new Intent(getApplicationContext(),AlarmCall.class);

intent.putExtra("PolicyNo3",policyNo2);

intent.putExtra("BarcodeNo",barcode_no);

Constants.pendingResultList.put(policyNo2, barcode_no);

System.out.println(Constants.pendingResultList.containsKey(policyNo2));

PendingIntent pendingIntent =
PendingIntent.getBroadcast(getApplicationContext(),
0,intent,PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmManager =
(AlarmManager)
getSystemService(ALARM_SERVICE);

long timedely = System.currentTimeMillis() +
(20*60*1000);

alarmManager.set(AlarmManager.RTC_WAKEUP,timedely,
pendingIntent);









////// Below is the code of ALarmCall.class






manger = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new
Notification(R.drawable.icon,"Please upload
result",System.currentTimeMillis());
Intent startActivity1 = new Intent();
startActivity1.setClass(context, UploadTest.class);
startActivity1.setAction(UploadTest.class.getName());
startActivity1.putExtra( "PolicyNo4",policyNo3);
startActivity1.putExtra("BarcodeNo1",barcodeNo);
startActivity1.addFlags(
Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);

PendingIntent contentIntent =
PendingIntent.getActivity(context,
0,startActivity1 ,Intent.FLAG_ACTIVITY_NEW_TASK);
notification.setLatestEventInfo(context, "HIV
Pharmacy","Result of
Id- "+policyNo3,contentIntent);
notification.flags = Notification.FLAG_ONLY_ALERT_ONCE |
Notification.FLAG_SHOW_LIGHTS;
notification.ledARGB = Color.GREEN;
notifica



Alarm manager for multiple pending intent are not working.

by Paul Turchenko » Mon, 16 Aug 2010 21:02:46 GMT


 endingIntent.FLAG* should help you.

On Aug 16, 12:44pm, Kostya Vasilyev <kmans...@gmail.com> wrote:

--



Alarm manager for multiple pending intent are not working.

by Mitesh Infocus » Tue, 17 Aug 2010 02:41:25 GMT


 commerce and Shopping cart Web portal Solutions at
www.infocuswebdesigning.com

We offer complete web services like, web designing, web development, Flash
websites, Flash Intros, E-commerce sites (os commerce, zen cart

sites) and much more at very cheap cost. For More Details & completed
Projects visit www.infocuswebdesigning.com
Contact us +91-79-650577772(16 lines) & Mob. +91 9725324241
Email : i...@infocuswebdesigning.com

On Mon, Aug 16, 2010 at 6:32 PM, Paul Turchenko <paul.turche...@gmail.com>wrote:

>



Alarm manager for multiple pending intent are not working.

by nomi » Tue, 17 Aug 2010 18:37:36 GMT


 Thanks to all for your response,

I have solved that problem by passing unique id which is depend on
current time:-

        final int intent_id= (int) System.currentTimeMillis();

                                        PendingIntent pendingIntent =
PendingIntent.getBroadcast(getApplicationContext(),intent_id,intent,PendingIntent.FLAG_UPDATE_CURRENT);

        by this change code is working properly and each pending
intent starts
specified activity after 20 mins of it's alarm off time.



--



Alarm manager for multiple pending intent are not working.

by Dianne Hackborn » Wed, 18 Aug 2010 01:00:34 GMT


 That's really janky.  I'd strongly recommend only posting one alarm, for the
next event you have in time, and upon processing that post a new alarm for
the following event.  This is how  most apps work.  Your code here is really
problematic in how it manages its alarms -- for example if you have an alarm
scheduled for something, and the user changes that thing's time or deletes
it, how do you remove the alarm from the alarm manager?




>



Other Threads

1. in app billing: PURCHASE_STATE_CHANGED sends empty orders

Dear list,

in 5-10% of all purchases, my BillingReceiver (basically taken from
the dungeons sample) gets a PURCHASE_STATE_CHANGED notification with
empty orders list:

05-08 17:15:17.294 D/BillingReceiver(13171)purchaseStateChanged:
{"nonce":4596323482244846986,"orders":[]}

The BillingService does not confirm this notification because that
code is never reached when orders is empty, but immediately I get a
RESPONSE_CODE with RESULT_OK.

The net result is that the user pays money but the app doesn't give
him anything for it, because it cannot process any order from an empty
list using BillingResponseHandler.purchaseResponse(). This is
obviously a bad thing.

The purchased item is in all known cases a non-managed in app product.

Is this known? Am I doing something wrong? How shall I handle this
case?

Thanks

Uwe

-- 

2. Phone crash on volume key

Hi,

    In my application (SDK 1.0.r2), after playing few sounds, I loose
the sounds. If I touch the volume keys, the device reboots. I get the
same behavior on the emulator. Anybody had the same problem?



12-16 14:15:49.892: ERROR/AudioFlinger(24): no more track names
availlable
12-16 14:15:49.892: ERROR/AudioTrack(24): Could not get control block
12-16 14:15:49.892: ERROR/AudioSink(24): Unable to create audio track
12-16 14:15:49.892: ERROR/VorbisPlayer(24): mAudioSink open failed
12-16 14:16:15.661: ERROR/AudioFlinger(24): no more track names
availlable
12-16 14:16:15.672: ERROR/AudioTrack(24): Could not get control block
12-16 14:16:15.672: ERROR/AudioSink(24): Unable to create audio track
12-16 14:16:15.672: ERROR/VorbisPlayer(24): mAudioSink open failed
12-16 14:16:50.431: DEBUG/VolumePanel(48): onVolumeChanged(streamType:
2, flags: 17)
12-16 14:16:50.431: DEBUG/VolumePanel(48): onShowVolumeChanged
(streamType: 2, flags: 17), index: 6
12-16 14:16:50.431: DEBUG/VolumePanel(48): setRingerIcon(index: 6),
ringerMode: 2
12-16 14:16:50.461: INFO/NotificationService(48): enqueueToast
pkg=android callback=android.widget.toast...@433f8408 duration=0
12-16 14:16:50.621: DEBUG/VolumePanel(48): onVolumeChanged(streamType:
2, flags: 4)
12-16 14:16:50.931: ERROR/AudioFlinger(24): no more track names
availlable
12-16 14:16:50.931: ERROR/AudioTrack(48): Could not get control block
12-16 14:16:50.931: ERROR/ToneGenerator(48): AudioTrack->initCheck
failed
12-16 14:16:50.931: ERROR/ToneGenerator(48): ToneGenerator init
failed
12-16 14:16:50.931: WARN/dalvikvm(48): threadid=15: thread exiting
with uncaught exception (group=0x40010e28)
12-16 14:16:50.931: ERROR/AndroidRuntime(48): Uncaught handler: thread
android.server.ServerThread exiting due to uncaught exception
12-16 14:16:50.931: ERROR/AndroidRuntime(48): *** EXCEPTION IN SYSTEM
PROCESS.  System will crash.
12-16 14:16:50.950: ERROR/AndroidRuntime(48):
java.lang.RuntimeException: Init failed
12-16 14:16:50.950: ERROR/AndroidRuntime(48):     at
android.media.ToneGenerator.native_setup(Native Method)
12-16 14:16:50.950: ERROR/AndroidRuntime(48):     at
android.media.ToneGenerator.<init>(ToneGenerator.java:225)
12-16 14:16:50.950: ERROR/AndroidRuntime(48):     at
android.view.VolumePanel.getOrCreateToneGenerator(VolumePanel.java:
258)
12-16 14:16:50.950: ERROR/AndroidRuntime(48):     at
android.view.VolumePanel.onPlaySound(VolumePanel.java:223)
12-16 14:16:50.950: ERROR/AndroidRuntime(48):     at
android.view.VolumePanel.handleMessage(VolumePanel.java:329)
12-16 14:16:50.950: ERROR/AndroidRuntime(48):     at
android.os.Handler.dispatchMessage(Handler.java:88)
12-16 14:16:50.950: ERROR/AndroidRuntime(48):     at
android.os.Looper.loop(Looper.java:123)
12-16 14:16:50.950: ERROR/AndroidRuntime(48):     at
com.android.server.ServerThread.run(SystemServer.java:308)
12-16 14:16:51.052: INFO/Process(48): Sending signal. PID: 48 SIG: 9


--~--~---------~--~----~------------~-------~--~----~

3. Mixing of voice

4. RatingBar

5. Segmentation fault when loading a certain class from an OSGi framework under Android 2.2 & 2.3

6. C Sharp Basics

7. Boot Camp: Mobile Application Development