Похоже, Справочник по API для NotificationManager немного испорчен.
Вот код, найденный через Поиск кода Google в NotificationManager и Android :
/**
* Persistent notification on the status bar,
*
* @param tag An string identifier for this notification unique within your
* application.
* @param notification A {@link Notification} object describing how to
* notify the user, other than the view you're providing. Must not be null.
* @return the id of the notification that is associated with the string identifier that
* can be used to cancel the notification
*/
public void notify(String tag, int id, Notification notification)
{
int[] idOut = new int[1];
INotificationManager service = getService();
String pkg = mContext.getPackageName();
if (localLOGV) Log.v(TAG, pkg + ": notify(" + id + ", " + notification + ")");
try {
service.enqueueNotificationWithTag(pkg, tag, id, notification, idOut);
if (id != idOut[0]) {
Log.w(TAG, "notify: id corrupted: sent " + id + ", got back " + idOut[0]);
}
} catch (RemoteException e) {
}
}
Очевидно, что параметр не возвращает значение. Они хотели иметь подобный JavaDoc, но, вероятно, допустили ошибку.
Посмотрите на код для другого варианта notify
:
/**
* Persistent notification on the status bar,
*
* @param id An identifier for this notification unique within your
* application.
* @param notification A {@link Notification} object describing how to
* notify the user, other than the view you're providing. Must not be null.
*/
public void notify(int id, Notification notification)
{
notify(null, id, notification);
}
Как видите, эта перегруженная версия просто вызывает основную реализацию со значением по умолчанию tag
Строковое значение null
.
Что касается общего вопроса о передаче по значению и передаче по ссылке, то простое / вульгарное объяснение таково:
- Java передает примитивы по значению,
- , но передает объекты по ссылке.
См. Комментарии Арнивана и Патрика для разъяснения.