Revision: 2367
http://sourceforge.net/p/swingme/code/2367
Author: yuranet
Date: 2019-03-08 10:23:48 +0000 (Fri, 08 Mar 2019)
Log Message:
-----------
update to use new api
Modified Paths:
--------------
AndroidME/src_MIDP/javax/microedition/midlet/MIDlet.java
Modified: AndroidME/src_MIDP/javax/microedition/midlet/MIDlet.java
===================================================================
--- AndroidME/src_MIDP/javax/microedition/midlet/MIDlet.java 2019-01-17 18:13:11 UTC (rev 2366)
+++ AndroidME/src_MIDP/javax/microedition/midlet/MIDlet.java 2019-03-08 10:23:48 UTC (rev 2367)
@@ -1,6 +1,7 @@
package javax.microedition.midlet;
import java.io.File;
+import java.lang.reflect.Method;
import java.util.Map;
import java.util.Properties;
import javax.microedition.io.ConnectionNotFoundException;
@@ -19,6 +20,7 @@
import android.content.Intent;
import android.net.MailTo;
import android.net.Uri;
+import android.os.Build;
import android.telephony.CellLocation;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
@@ -380,18 +382,43 @@
PendingIntent intent = PendingIntent.getActivity(context, 0, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT);
- Notification notif = new Notification(icon, message, System.currentTimeMillis());
- notif.iconLevel = 3;
- //notif.vibrate = new long[] {100,100,200,300};
- notif.defaults = Notification.DEFAULT_ALL;
- notif.ledOnMS = 100;
- notif.ledOffMS = 100;
- notif.flags |= Notification.FLAG_AUTO_CANCEL;
- if (number > 0) {
- notif.number = number;
+ Notification notif;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
+ // Use new API
+ Notification.Builder notification = new Notification.Builder(context)
+ .setContentIntent(intent)
+ .setSmallIcon(icon)
+ .setContentTitle(title)
+ .setContentText(message)
+ .setAutoCancel(true);
+
+ if (number > 0) {
+ notification.setNumber(number);
+ }
+
+ notif = notification.build();
}
- notif.setLatestEventInfo(context, title, message, intent);
+ else {
+ notif = new Notification(icon, message, System.currentTimeMillis());
+ notif.iconLevel = 3;
+ //notif.vibrate = new long[] {100,100,200,300};
+ notif.defaults = Notification.DEFAULT_ALL;
+ notif.ledOnMS = 100;
+ notif.ledOffMS = 100;
+ notif.flags |= Notification.FLAG_AUTO_CANCEL;
+ if (number > 0) {
+ notif.number = number;
+ }
+
+ try {
+ Method deprecatedMethod = notif.getClass().getMethod("setLatestEventInfo", Context.class, CharSequence.class, CharSequence.class, PendingIntent.class);
+ deprecatedMethod.invoke(notif, context, title, message, intent);
+ } catch (Exception e) {
+ Logger.warn("setLatestEventInfo error", e);
+ }
+ }
+
NotificationManager notifManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notifManager.notify(0, notif);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|