Android notification don't appear
Unsolved
Mobile and Embedded
-
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 codepackage 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