When porting the Notifier example to my own project (basically copying the .h, .cpp and .java files over), and calling as shown in the Notifier example, I get this error:

Qt Code:
  1. W System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.app.Activity.getSystemService(java.lang.String)' on a null object reference
To copy to clipboard, switch view to plain text mode 

It occurs when running this Java code:

Qt Code:
  1. public static void notify(String s)
  2. {
  3. try {
  4. if (m_notificationManager == null) {
  5. m_notificationManager = (NotificationManager)m_instance.getSystemService(Context.NOTIFICATION_SERVICE);
  6. m_builder = new Notification.Builder(m_instance);
  7. m_builder.setSmallIcon(R.drawable.icon);
  8. m_builder.setContentTitle("A message from Qt!");
  9. }
  10.  
  11. m_builder.setContentText(s);
  12. m_notificationManager.notify(1, m_builder.build());
  13. } catch(Throwable e) {
  14. e.printStackTrace();
  15. }
  16. }
To copy to clipboard, switch view to plain text mode 

To me it appears that the 'm_instance' variable is null... but why? If I open and run the Notifier example, it works fine.