use of com.codename1.util.Callback in project CodenameOne by codenameone.
the class PushNotificationService method push.
@Override
public void push(final String value) {
final PushCallback callback = getPushCallbackInstance();
if (callback != null) {
Display.getInstance().callSerially(new Runnable() {
public void run() {
callback.push(value);
}
});
} else {
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Intent newIntent = new Intent(this, getStubClass());
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, newIntent, PendingIntent.FLAG_CANCEL_CURRENT);
Notification.Builder builder = new Notification.Builder(this).setContentIntent(contentIntent).setSmallIcon(android.R.drawable.stat_notify_sync).setTicker(value).setAutoCancel(true).setWhen(System.currentTimeMillis()).setContentTitle(value).setDefaults(Notification.DEFAULT_ALL);
Notification notif = builder.build();
nm.notify((int) System.currentTimeMillis(), notif);
}
}
Aggregations