Question on NotificationManager, setLatestEventInfo() and custom view.

by Jiri » Sat, 24 Oct 2009 00:07:38 GMT


Sponsored Links
 Hello,

I am creating a notification that displayes the progress of downloading 
files. Because I use a custom layout to be displyed in the expanded 
view. This custom view has a progressbar. I first make a call to the 
notification manager that will show the progress bar as being 
indeterminate and display a text "2 / 10" for instance.
Then when the downloading starts i only want to update the prgress bar.

<code>
     private void showNotification(String tickertxt, String displayTxt , 
  int total , int progress , Boolean indeterminate) {

         NotificationManager notifMgr = (NotificationManager) 
this.getSystemService(Service.NOTIFICATION_SERVICE);

        PendingIntent contentIntent = PendingIntent.getActivity(this, 0, 
new Intent(this, MainMenu.class), 0);

        // construct the Notification object.
        Notification notif = new Notification();

        notif.flags = Notification.FLAG_ONGOING_EVENT | 
Notification.FLAG_ONLY_ALERT_ONCE;
        notif.tickerText = tickertxt;
        notif.icon = R.drawable.icon;

        RemoteViews nmView = new RemoteViews( getPackageName(), 
R.layout.custom_notification_layout);
        nmView.setProgressBar(R.id.progressbar, total, progress, 
indeterminate);
        nmView.setTextViewText(R.id.TextView01, displayTxt);

        notif.contentView = nmView;

        notif.contentIntent = contentIntent;

         notifMgr.notify(R.layout.custom_notification_layout,  notif);
     }

</code>
So the first call i make when downloads are being prepared is:

showNotification("download..." , "n / n files" , 1 , 1 , false)

then when downloading starts:


showNotification("download..." , "n / n files" , class.getCurrent() , 
class.getTotal() , true)


What is bothering me is that I call the second call quit a lot and thus 
in the showNotification() a lot of objects are instantiated. In the docs 
it talks about  setLatestEventInfo() but this (afaik) cannot be applied 
when using a custom view.
Is this the way it is or is there a better technique.

Jiri



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



Other Threads

1. Revised: Android V2 Keystor

You may have heard debates concerning the virtues of "soft certificates" versus 
"smart cards".

I have come to the conclusion that this distinction is mostly based on the fact
that current smart cards cannot be provisioned in a secure way over the Internet
to an end-user because there is nothing in the card that can vouch for the 
origin of
generated key-pairs (and a lot of other related stuff as well).

Is there a need for a such a facility?  Yes, unless you think this is cool:
http://www.trustdigital.com/downloads/TD_EMM_CAC_Pack_101008.pdf
http://na.blackberry.com/eng/ataglance/security/products/smartcardreader
IMO these solutions represent $200+ of total c**p.

A better solution would of course be that you used your PIV/CAC/eID card
to "enroll2 your mobile device which then should be on par with the original
credential security-wise!  This can be done by the end-user itself.

Rather than "only" making a phone solution, I have revised the Android V2
Keystore project to also work with firmware-enhanced smart cards that should
be able to use the same provisioning protocol.

The details are yet to be described publicly but I see no problems achieving
what is claimed in:

"Air-tight" provisioning, the basics:
http://webpki.org/papers/keygen2/secure-key-store.pdf
"Air-tight" provisioning", core facility:
http://webpki.org/papers/keygen2/session-key-establishment--security-element-2-server.pdf

Anders

2. I found the minus key on the android emulator

I have been battling with the issue of how to enter a negative number
into an EditText. I have discovered the answer to the problem and
would like to share it. The minus key on the android emulator is the
"g" key. This seems to be a surprising place for it to be at first,
but with the benefit of hindsight, it is to the immediate right of the
center of the alternative  "calculator style" numeric keyboard that
you get when you specify numeric input for an EditText. It is
unfortunate that the numerals and the minus sign are not shown on
these keys.

Thanks to those who replied to me and tried to help.


Mike
--~--~---------~--~----~------------~-------~--~----~

3. Problem with createBitmap method

4. fast removing SurfaceView

5. HelloAndroid not working...

6. Who can explain on 'pv2way'?

7. Blocking Access from phone