1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
if (!MonActivity.isInForeground) {
Resources resources = context.getResources();
String identifier = intent
.getStringExtra(MyActivity.PARAM_EXCHANGE_IDENTIFIER);
// Do the graphical update or record data
if (identifier.equals(MyActivity.EXCHANGE)) {
SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(context);
Resources res = context.getResources();
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.ic_my_icon,
res.getText(R.string.my_text), System.currentTimeMillis());
notification.number++;
PendingIntent pending = PendingIntent.getActivity(context, 0, new Intent(context, MyActivity.class), 0);
notification.setLatestEventInfo(context, resources.getString(R.string.app_name),
res.getText(R.string.my_text), pending);
notification.ledARGB = Notification.DEFAULT_LIGHTS;
notification.vibrate = new long[] {0,100,200,300};
notification.sound = Uri.parse(appPrefs.getString(resources.getString(R.string.ringtonePrefs), ""));
notificationManager.notify(resources.getString(R.string.app_name), MY_ID, notification);
}
} |
Partager