C
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 } |
Properties
|
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 |
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.
Constant | Value | Description |
---|---|---|
QAndroidNotificationItem::BigText | 0 | Same as Android Notification's key EXTRA_BIG_TEXT |
QAndroidNotificationItem::CallPerson | 1 | Same as Android Notification's key EXTRA_CALL_PERSON |
QAndroidNotificationItem::Colorized | 2 | Same as Android Notification's key EXTRA_COLORIZED |
QAndroidNotificationItem::ConversationTitle | 3 | Same as Android Notification's key EXTRA_CONVERSATION_TITLE |
QAndroidNotificationItem::InfoText | 4 | Same as Android Notification's key EXTRA_INFO_TEXT |
QAndroidNotificationItem::IsGroupConversation | 5 | Same as Android Notification's key EXTRA_IS_GROUP_CONVERSATION |
QAndroidNotificationItem::LargeIconBig | 6 | Same as Android Notification's key EXTRA_LARGE_ICON_BIG |
QAndroidNotificationItem::MediaSession | 7 | Same as Android Notification's key EXTRA_MEDIA_SESSION |
QAndroidNotificationItem::Messages | 8 | Same as Android Notification's key EXTRA_MESSAGES |
QAndroidNotificationItem::MessagingPerson | 9 | Same as Android Notification's key EXTRA_MESSAGING_PERSON |
QAndroidNotificationItem::PeopleList | 10 | Same as Android Notification's key EXTRA_PEOPLE_LIST |
QAndroidNotificationItem::Picture | 11 | Same as Android Notification's key EXTRA_PICTURE |
QAndroidNotificationItem::Progress | 12 | Same as Android Notification's key EXTRA_PROGRESS |
QAndroidNotificationItem::ProgressIndeterminate | 13 | Same as Android Notification's key EXTRA_PROGRESS_INDETERMINATE |
QAndroidNotificationItem::ProgressMax | 14 | Same as Android Notification's key EXTRA_PROGRESS_MAX |
QAndroidNotificationItem::ShowWhen | 15 | Same as Android Notification's key EXTRA_SHOW_WHEN |
QAndroidNotificationItem::SubText | 16 | Same as Android Notification's key EXTRA_SUB_TEXT |
QAndroidNotificationItem::SummaryText | 17 | Same as Android Notification's key EXTRA_SUMMARY_TEXT |
QAndroidNotificationItem::Template | 18 | Same as Android Notification's key EXTRA_TEMPLATE |
QAndroidNotificationItem::TitleBig | 19 | Same as Android Notification's key EXTRA_TITLE_BIG |
QAndroidNotificationItem::VerificationIcon | 20 | Same as Android Notification's key EXTRA_VERIFICATION_ICON |
QAndroidNotificationItem::VerificationText | 21 | Same 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.
Constant | Value | Description |
---|---|---|
QAndroidNotificationItem::Visibility::Secret | -1 | Same as Android Notification's VISIBILITY_SECRET |
QAndroidNotificationItem::Visibility::Private | 0 | Same as Android Notification's VISIBILITY_PRIVATE |
QAndroidNotificationItem::Visibility::Public | 1 | Same 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.