Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Android notification don't appear
Qt 6.11 is out! See what's new in the release blog

Android notification don't appear

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
1 Posts 1 Posters 462 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kamelEddine
    wrote on last edited by
    #1

    hello , I have problem with android notification , i just copied the java and notificationClient class from qt notification example ,and register new type in my main

         qmlRegisterType<NotificationClient>("notification",1,0,"Notification");
    
    

    of course i added

    QT +=androidextras
    ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android-sources
    

    and changed the package name in java code
    this is the java code

    
    package org.qtproject.example.androidpi;
    
    import android.app.Notification;
    import android.app.NotificationManager;
    import android.content.Context;
    
    public class NotificationClient extends org.qtproject.qt5.android.bindings.QtActivity
    {
        private static NotificationManager m_notificationManager;
        private static Notification.Builder m_builder;
        private static NotificationClient m_instance;
    
        public NotificationClient()
        {
            m_instance = this;
        }
    
        public static void notify(String s)
        {
            if (m_notificationManager == null) {
                m_notificationManager = (NotificationManager)m_instance.getSystemService(Context.NOTIFICATION_SERVICE);
                m_builder = new Notification.Builder(m_instance);
                m_builder.setSmallIcon(R.drawable.icon);
                m_builder.setContentTitle("A message from Qt!");
            }
    
            m_builder.setContentText(s);
            m_notificationManager.notify(1, m_builder.build());
        }
    }
    
    

    when i compile all work fine but notification don't appear ,if you want more information i can give all the code

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved