[android-developers] multiple notifications
hi as a part of application i need to notify the files downloaded but when downloading the other file after one completed the notification displayed is changing to the current download and the notification for the before download is not displaying import android.app.Activity; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.os.Bundle; public class Notify extends Activity { private static final int NOTIFY_ID = 1; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); int icon = R.drawable.icon;// icon from resources CharSequence tickerText = Hello; // ticker-text long when = System.currentTimeMillis(); // notification time Context context = getApplicationContext(); // application Context CharSequence contentTitle = My notification; // expanded message title CharSequence contentText = Hello World!; // expanded message text Intent notificationIntent = new Intent(this, Notify.class); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); // the next two lines initialize the Notification, using the configurations above Notification notification = new Notification(icon, tickerText, when); notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); mNotificationManager.notify(NOTIFY_ID, notification); } } this is the code -- 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] Multiple notifications, single icon on notification bar?
Hi, If I do: for (int i = 0; i 3; i++) { NotificationManager.notify(i, notification); } I'll get three notification icons on the notification bar, and three list items in the pull down. Is there a way to use only one icon on the notification bar, but still keep three entries in the pull down? I tried doing: for (int i = 0; i 3; i++) { if (i 0) { notification.number = -1; } NotificationManager.notify(i, notification); } but no luck. The docs say that setting notification.number to zero or a negative # will prevent it from showing up on the notifications bar, 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] Multiple notifications, single icon on notification bar?
On Thu, Jun 3, 2010 at 5:30 PM, Mark Wyszomierski mar...@gmail.com wrote: Is there a way to use only one icon on the notification bar, but still keep three entries in the pull down? Don't think so - each icon represents an entry in the pull down - having one icon represent multiple entries wouldn't really make sense. The docs say that setting notification.number to zero or a negative # will prevent it from showing up on the notifications bar, This prevents the number that's overlayed on the icon from showing up, not the icon itself. - TreKing - Chicago transit tracking app for Android-powered devices http://sites.google.com/site/rezmobileapps/treking -- 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] Multiple Notifications - PendingNotifications with different data?
Let's say I have a background service that performs several tasks. As it completes task A, it posts notification A with a certain intent and some extra data that indicates viewing result of A. As it completes task B, it posts notification B with a certain intent and some extra data that indicates viewing result of B. As it completes task C, it posts notification C with a certain intent and some extra data that indicates viewing result of C. At the end, the notification area has three notifications. Each one has the same intent, except for one of the extra data fields. I would expect that each one would load my activity with different extra data. They don't. When onNewIntent is called, each has the extra data field set to C. I have rooted out any possible aliasing and checked the data as it is placed into a notification. It seems to allow only one set of data per package. Is what I am attempting not possible? Has anyone accomplished what I am attempting? For example, have you had a service download several large files, and then had notifications that would open each of those files? This is some of the relevant code: // post a finished notification. Notification finished = new Notification(R.drawable.notifier, tickerText, System.currentTimeMillis()); Intent intent = new Intent(); intent.setClass(DownloadService.this, MyActivity.class); intent.setAction(MyActivity.OPEN_LOCATION); // adding parameters to extras .. intent.putExtra(packageName.layer, layer); ... // The PendingIntent to launch our activity if the user selects this // notification PendingIntent contentIntent = PendingIntent.getActivity(DownloadService.this, 0, intent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT | Intent.FILL_IN_DATA); String contentTitle = getString(R.string.n_download_completed); String contentText = getString(R.string.n_download_results, layer); finished.setLatestEventInfo(DownloadService.this, contentTitle, contentText, contentIntent); mNotificationManager.notify(finishedid++, finished); Nathan -- 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] Multiple Notifications - PendingNotifications with different data?
Nathan wrote: Let's say I have a background service that performs several tasks. As it completes task A, it posts notification A with a certain intent and some extra data that indicates viewing result of A. As it completes task B, it posts notification B with a certain intent and some extra data that indicates viewing result of B. As it completes task C, it posts notification C with a certain intent and some extra data that indicates viewing result of C. At the end, the notification area has three notifications. Each one has the same intent, except for one of the extra data fields. I would expect that each one would load my activity with different extra data. They don't. When onNewIntent is called, each has the extra data field set to C. I have rooted out any possible aliasing and checked the data as it is placed into a notification. It seems to allow only one set of data per package. Is what I am attempting not possible? Has anyone accomplished what I am attempting? For example, have you had a service download several large files, and then had notifications that would open each of those files? This is some of the relevant code: // post a finished notification. Notification finished = new Notification(R.drawable.notifier, tickerText, System.currentTimeMillis()); Intent intent = new Intent(); intent.setClass(DownloadService.this, MyActivity.class); intent.setAction(MyActivity.OPEN_LOCATION); // adding parameters to extras .. intent.putExtra(packageName.layer, layer); ... // The PendingIntent to launch our activity if the user selects this // notification PendingIntent contentIntent = PendingIntent.getActivity(DownloadService.this, 0, intent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT | Intent.FILL_IN_DATA); use PendingIntent.getActivity with unique requestCode pskink -- 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] Multiple Notifications - PendingNotifications with different data?
Nathan wrote: Let's say I have a background service that performs several tasks. As it completes task A, it posts notification A with a certain intent and some extra data that indicates viewing result of A. As it completes task B, it posts notification B with a certain intent and some extra data that indicates viewing result of B. As it completes task C, it posts notification C with a certain intent and some extra data that indicates viewing result of C. At the end, the notification area has three notifications. Each one has the same intent, except for one of the extra data fields. I would expect that each one would load my activity with different extra data. They don't. PendingIntent.getActivity() will return a unique PendingIntent object *only* if the Intent you supply to that call is materially different than those used by other outstanding PendingIntents. By materially different, I mean where Intent#filterEquals() returns false. In your case, your three Intents are all the same from the perspective of filterEquals(), because filterEquals() does not take extras into account. Hence, you need to make three more distinct Intents. If your intents right now are using the component (e.g., new Intent(this, SomeActivity.class)), the easy way to do this is to assign some unique action string to them. That won't affect how the Intent gets routed, but it will make it distinct from a filterEquals() standpoint. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Online Training: 21-25 June 2010: http://onlc.com -- 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] Multiple Notifications - PendingIntents with different data?
Let's say I have a background service that performs several tasks. As it completes task A, it posts notification A with a certain intent and some extra data that indicates viewing result of A. As it completes task B, it posts notification B with a certain intent and some extra data that indicates viewing result of B. As it completes task C, it posts notification C with a certain intent and some extra data that indicates viewing result of C. At the end, the notification area has three notifications. Each one has the same intent, except for one of the extra data fields. I would expect that each one would load my activity with different extra data. They don't. When onNewIntent is called, each has the extra data field set to C. I have rooted out any possible aliasing and checked the data as it is placed into a notification. It seems to allow only one set of data per package. Is what I am attempting not possible? Has anyone accomplished what I am attempting? For example, have you had a service download several large files, and then had notifications that would open each of those files? This is some of the relevant code: // post a finished notification. Notification finished = new Notification(R.drawable.notifier, tickerText, System.currentTimeMillis()); Intent intent = new Intent(); intent.setClass(DownloadService.this, MyActivity.class); intent.setAction(MyActivity.OPEN_LOCATION); // adding parameters to extras .. intent.putExtra(packageName.layer, layer); ... // The PendingIntent to launch our activity if the user selects this // notification PendingIntent contentIntent = PendingIntent.getActivity(DownloadService.this, 0, intent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT | Intent.FILL_IN_DATA); String contentTitle = getString(R.string.n_download_completed); String contentText = getString(R.string.n_download_results, layer); finished.setLatestEventInfo(DownloadService.this, contentTitle, contentText, contentIntent); mNotificationManager.notify(finishedid++, finished); Nathan -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android- develop...@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 -- 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] Multiple Notifications
Hi, I have a notification which is being created with a PendingIntent setup with some extras in the Intent. After the first notification is created, all subsequent notifications have the same values in their extras as the first, even though the notification and the extras are being updated. This means that when the notification is selected and a value is taken from the extra (eg. timestamp) it has the timestamp of the first notification rather than the most recent. All the books I read say that when the notifiers match the old Notification is updated instead of creating a new one (or something along those lines). If this isn't how it works, is there a way to achieve a change in the information attached to the notification? Thanks in advance. -- 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] Multiple notifications difficulties...
Is there something special one needs to do, if you want to have multiple notices. I am getting really strange behavior. When I post multiple notices..each notices results in additional icon in the status bar. And when I click on any of those icons it list all the notices that have been posted. but if i click on any of the posted notices it always launches the intent of the first notice that was posted..not the intent of the actually notice that was clicked on. So is there any documentation that explains how to post more than one notification/ the code looks like the following. Notification note=new Notification( R.drawable.notice_icon, message.getTitle(), System.currentTimeMillis()); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, SelectConversation.class) .putExtra(messageId, message.getId()) , 0); note.setLatestEventInfo(this, message.getTitle(), message.getMessage(), pendingIntent); note.defaults = Notification.DEFAULT_ALL; notificationManager.notify((int) message.getId(), note); --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---