Android - Send a simple notification



  • Hello everyone!
    I recently started working on an app that should have a simple user interface - its main task is to regularly synchronize data between a personal server and a small, Bluetooth-connected wearable device.

    I recently wanted to send a simple, standard Android notification to indicate connection problems or a low battery of the device.
    From what I could gather, building the QtApplicationManager was necessary.

    I have built and properly installed the QtApplicationManager (or at the very least, qmake, make and make install returned no errors, and left files in the Qt/5.11.1 dirs for both gcc_64 and android).

    However, when trying to include the newly installed module in the .pro file, nothing seems to work. I've tried applicationmanager with or without hyphen, with or without qt, capitalization, etc.
    So either I haven't hit the right module name yet, or it simply isn't working.

    My question is now:

    • Is there a way to send standard notifications on Android without building an entirely separate module? One would think sending system notifications should be doable by default.
    • If not, how do I properly install and include the QtApplicationManager QML type in my project in order to use its Notification type?

    I am running Debian 9, Qt 5.11.1 for gcc_64 and android_armeabi-v7a (with gcc 4.9 and Qt 5.11.1 also)


  • Lifetime Qt Champion

    Hi,

    Are you thinking about something like the Qt Notifier example ?



  • Hi!
    That looks like it could fulfill my needs too, but I'll have to play around with the class a bit.
    Thanks for pointing it out!
    I probably saw the "QtApplicationManager" QML "Notification" type and got side-tracked by that.

    How come Qt does not offer a native way of sending system notifications though, independent of the platform the application is being run on?


  • Moderators

    @Xasin said in Android - Send a simple notification:

    How come Qt does not offer a native way of sending system notifications though, independent of the platform the application is being run on?

    Because its hard to get a common base for notifications (which actually helps in most use cases)
    Not every notification looks the same, nor is the origin which triggers the notification the same.
    For example on android normally an app doesn't need to trigger a notification, since it's only guaranteed that your app is running when the user has currently opened it. If the user switches away from your app, the android system might close your app for the sake of resources. So then there is no code to run to trigger the notification. You would need to create a background service to make sure your notification will be shown.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.