QAndroidNotificationItem Class

The QAndroidNotificationItem class holds information of a notification posted in Android. It combines two Android classes, StatusBarNotification and Notification to provide all the information related to the posted notification. More...

Header: #include <QAndroidNotificationItem>
CMake: find_package(Qt6 REQUIRED COMPONENTS AndroidAutomotiveBase)
target_link_libraries(mytarget PRIVATE Qt6::AndroidAutomotiveBase)
Since: Qt 6.4
Inherits: QObject

Public Types

enum ExtraKey { BigText, CallPerson, Colorized, ConversationTitle, InfoText, …, VerificationText }
enum class Visibility { Secret, Private, Public }


Public Functions

QAndroidNotificationItem(const QJniObject &javaNotification, QObject *parent = nullptr)
QList<QAndroidNotificationAction *> actions() const
QString content() const
QVariant extra(QAndroidNotificationItem::ExtraKey key) const
QVariant extra(const QString &key) const
QImage iconLarge() const
QString iconLargeString() const
QImage iconSmall() const
QString iconSmallString() const
bool isClearable() const
bool isValid() const
QString key() const
int notificationId() const
QString packageName() const
QDateTime postTime() const
QString title() const
QAndroidNotificationItem::Visibility visibility() const

Public Slots

void performContentAction() const

Detailed Description

See also QAndroidNotificationListener.

Member Type Documentation

enum QAndroidNotificationItem::ExtraKey

This enum type specifies a variety of keys to access extra data provided with the notification. The values correspond to keys defined in Android's Notification class. The enum provides the most common keys for convenience, with the exception of extras that have their own properties, like for example QAndroidNotificationItem::title. If an extra key is not included in the enum, QAndroidNotificationItem::extra(const &QString key) can be used to fetch the desired extra with the string key directly.

QAndroidNotificationItem::BigText0Same as Android Notification's key EXTRA_BIG_TEXT
QAndroidNotificationItem::CallPerson1Same as Android Notification's key EXTRA_CALL_PERSON
QAndroidNotificationItem::Colorized2Same as Android Notification's key EXTRA_COLORIZED
QAndroidNotificationItem::ConversationTitle3Same as Android Notification's key EXTRA_CONVERSATION_TITLE
QAndroidNotificationItem::InfoText4Same as Android Notification's key EXTRA_INFO_TEXT
QAndroidNotificationItem::IsGroupConversation5Same as Android Notification's key EXTRA_IS_GROUP_CONVERSATION
QAndroidNotificationItem::LargeIconBig6Same as Android Notification's key EXTRA_LARGE_ICON_BIG
QAndroidNotificationItem::MediaSession7Same as Android Notification's key EXTRA_MEDIA_SESSION
QAndroidNotificationItem::Messages8Same as Android Notification's key EXTRA_MESSAGES
QAndroidNotificationItem::MessagingPerson9Same as Android Notification's key EXTRA_MESSAGING_PERSON
QAndroidNotificationItem::PeopleList10Same as Android Notification's key EXTRA_PEOPLE_LIST
QAndroidNotificationItem::Picture11Same as Android Notification's key EXTRA_PICTURE
QAndroidNotificationItem::Progress12Same as Android Notification's key EXTRA_PROGRESS
QAndroidNotificationItem::ProgressIndeterminate13Same as Android Notification's key EXTRA_PROGRESS_INDETERMINATE
QAndroidNotificationItem::ProgressMax14Same as Android Notification's key EXTRA_PROGRESS_MAX
QAndroidNotificationItem::ShowWhen15Same as Android Notification's key EXTRA_SHOW_WHEN
QAndroidNotificationItem::SubText16Same as Android Notification's key EXTRA_SUB_TEXT
QAndroidNotificationItem::SummaryText17Same as Android Notification's key EXTRA_SUMMARY_TEXT
QAndroidNotificationItem::Template18Same as Android Notification's key EXTRA_TEMPLATE
QAndroidNotificationItem::TitleBig19Same as Android Notification's key EXTRA_TITLE_BIG
QAndroidNotificationItem::VerificationIcon20Same as Android Notification's key EXTRA_VERIFICATION_ICON
QAndroidNotificationItem::VerificationText21Same as Android Notification's key EXTRA_VERIFICATION_TEXT

enum class QAndroidNotificationItem::Visibility

This enum type specifies values correspond to the return value of Android Notification's visibility of Android's Notification class. QAndroidNotificationItem::visibility() can be used to get the value for an Android notification.

QAndroidNotificationItem::Visibility::Secret-1Same as Android Notification's VISIBILITY_SECRET
QAndroidNotificationItem::Visibility::Private0Same as Android Notification's VISIBILITY_PRIVATE
QAndroidNotificationItem::Visibility::Public1Same as Android Notification's VISIBILITY_PUBLIC

Property Documentation

[read-only] actions : QList<QAndroidNotificationAction*> const

This property holds a list of QAndroidNotificationAction pointers.

Access functions:

QList<QAndroidNotificationAction *> actions() const

[read-only] clearable : const bool

This property holds whether the notification can be dismissed by the user.

Access functions:

bool isClearable() const

[read-only] content : const QString

This property holds the notification's content text.

Access functions:

QString content() const

[read-only] iconLarge : const QString

This property holds the notification's large icon, shown in the content view.

Access functions:

QString iconLargeString() const

[read-only] iconSmall : const QString

This property holds the notification's small icon, which represents the notification in the status bar and content view.

Access functions:

QString iconSmallString() const

[read-only] key : const QString

This property holds the notification key. The key is unique for this notification.

Access functions:

QString key() const

[read-only] notificationId : const int

This property holds the notification ID of the posted Android notification. The ID will be unique within the app that posted the notification.

Access functions:

int notificationId() const

[read-only] packageName : const QString

This property holds the name of the package this notification belongs to.

Access functions:

QString packageName() const

[read-only] postTime : const QDateTime

This property holds the time when the notification was posted.

Access functions:

QDateTime postTime() const

[read-only] title : const QString

This property holds the notification's title.

Access functions:

QString title() const

[read-only] valid : const bool

This property holds whether the constructed notification is valid. Returns true if the underlying QJniObject was successfully created from the received Android notification.

Access functions:

bool isValid() const

[read-only] visibility : const Visibility

This property holds the visibility of the notification.

Access functions:

QAndroidNotificationItem::Visibility visibility() const

See also QAndroidNotificationItem::Visibility.

Member Function Documentation

[explicit] QAndroidNotificationItem::QAndroidNotificationItem(const QJniObject &javaNotification, QObject *parent = nullptr)

Constructs a QAndroidNotificationItem wrapping the javaNotification, with the given parent.

QVariant QAndroidNotificationItem::extra(QAndroidNotificationItem::ExtraKey key) const

Returns additional data provided to this notification, specified by key. Similar to QAndroidNotificationItem::extra(const QString &key), but accepts an ExtraKey value for convenience. The returned value will be a QJniObject wrapped in a QVariant. If the requested extra field is empty, the QJniObject will be invalid.

See also QAndroidNotificationItem::ExtraKey.

QVariant QAndroidNotificationItem::extra(const QString &key) const

Returns additional data provided to this notification, specified by key. Similar to extra(ExtraKey key), but allows specifying the key as text. The key should be one of the extra keys defined in Android's Notification class. The returned value will be a QJniObject wrapped in a QVariant. If the requested extra field is empty, the returned QVariant will include an invalid QJniObject. To access the value, the following can be used:

QVariant extra = notificationItem->getExtra(QAndroidNotificationItem::BigText);
QJniObject extraObject = qvariant_cast<QJniObject>(extra);
if (extraObject.isValid()) {
    QString stringExtra = extraObject.toString();

QImage QAndroidNotificationItem::iconLarge() const

Returns the notification's large icon as a QImage.

See also QAndroidNotificationItem::iconSmall().

QImage QAndroidNotificationItem::iconSmall() const

Returns the notification's small icon as a QImage.

See also QAndroidNotificationItem::iconLarge().

[slot] void QAndroidNotificationItem::performContentAction() const

Sends the contentIntent defined in Android's Notification class if it is valid.

Available under certain Qt licenses.
Find out more.