I can use JNI to issue a notification using a java file. The only way I can do that is by replacing the activity line in the manifest like so: From:
<activity android:name="org.qtproject.qt5.android.bindings.QtActivity" >
To the path for the java file:
<activity android:name="org.qtproject.example.notification.NotificationClient" >
or else the notifications won't show up!
What if I want to Use more than one Java file to do other stuff using JNI? How can I add more than one activity in the manifest?
This is my NotificationClient.java:
package org.qtproject.example.notification;
import android.app.Notification;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.app.PendingIntent;
import android.app.Activity;
import org.qtproject.qt5.android.bindings.QtActivity;
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;
private static PendingIntent contentIntent;
private static Intent intent;
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.icon2);
m_builder.setDefaults(Notification.DEFAULT_SOUND);
m_builder.setContentTitle("A message from Qt!");
}
intent = new Intent(m_instance, NotificationClient.class);
contentIntent = PendingIntent.getActivity(m_instance, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
m_builder.setContentIntent(contentIntent);
m_builder.setContentText(s);
m_notificationManager.notify(1, m_builder.build());
}
}