From 2e6de8fdccf71dc733864c1ea757182cc13303ab Mon Sep 17 00:00:00 2001 From: Scott Main Date: Tue, 30 Apr 2013 10:51:12 -0700 Subject: add notice to not use 0 in startForeground(). also delete some obsolete back-compat tips for <=donut bug: 8746126 Change-Id: I3ee966647aa2c9f572e6f02eeabfc2cf925a031f --- core/java/android/app/Service.java | 2 +- docs/html/guide/components/services.jd | 26 ++++---------------------- 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/core/java/android/app/Service.java b/core/java/android/app/Service.java index 4fbca7318c27..396774090515 100644 --- a/core/java/android/app/Service.java +++ b/core/java/android/app/Service.java @@ -633,7 +633,7 @@ public abstract class Service extends ContextWrapper implements ComponentCallbac * * @param id The identifier for this notification as per * {@link NotificationManager#notify(int, Notification) - * NotificationManager.notify(int, Notification)}. + * NotificationManager.notify(int, Notification)}; must not be 0. * @param notification The Notification to be displayed. * * @see #stopForeground(boolean) diff --git a/docs/html/guide/components/services.jd b/docs/html/guide/components/services.jd index 6e5dfd2f8148..30da33af204d 100644 --- a/docs/html/guide/components/services.jd +++ b/docs/html/guide/components/services.jd @@ -252,19 +252,6 @@ document.

Creating a Started Service

- -

A started service is one that another component starts by calling {@link android.content.Context#startService startService()}, resulting in a call to the service's {@link android.app.Service#onStartCommand onStartCommand()} method.

@@ -687,9 +674,12 @@ Intent notificationIntent = new Intent(this, ExampleActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); notification.setLatestEventInfo(this, getText(R.string.notification_title), getText(R.string.notification_message), pendingIntent); -startForeground(ONGOING_NOTIFICATION, notification); +startForeground(ONGOING_NOTIFICATION_ID, notification); +

Caution: The integer ID you give to {@link +android.app.Service#startForeground startForeground()} must not be 0.

+

To remove the service from the foreground, call {@link android.app.Service#stopForeground stopForeground()}. This method takes a boolean, indicating @@ -697,14 +687,6 @@ whether to remove the status bar notification as well. This method does not< service. However, if you stop the service while it's still running in the foreground, then the notification is also removed.

-

Note: The methods {@link -android.app.Service#startForeground startForeground()} and {@link -android.app.Service#stopForeground stopForeground()} were introduced in Android 2.0 (API Level -5). In order to run your service in the foreground on older versions of the platform, you must -use the previous {@code setForeground()} method—see the {@link -android.app.Service#startForeground startForeground()} documentation for information about how -to provide backward compatibility.

-

For more information about notifications, see Creating Status Bar Notifications.

-- cgit v1.2.3-59-g8ed1b