Slide 9
Slide 9 text
9
Tworzenie powiadomień (old school)
●
powiadomienia realizowane są przez usługę NotificationManager
int NOTIFICATION_ID = 1;
NotificationManager notifier = (NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
Notification n = new Notification();
n.icon = android.R.drawable.stat_notify_error;
n.tickerText = "Tekst przewijany";
n.when = System.currentTimeMillis();
n.flags |= Notification.FLAG_AUTO_CANCEL;
Intent intent = new Intent(MyActivity.this, MyActivity.class);
PendingIntent pending = PendingIntent.getActivity(MyActivity.this, 0, intent, 0);
n.setLatestEventInfo(MyActivity.this, "Tytul", "Tresc", pending);
notifier.notify(NOTIFICATION_ID, n);
●
dodatkowe parametry powiadomień
n.vibrate = new long[] { 300, 200, 300, 200 };
n.flags |= Notification.FLAG_SHOW_LIGHTS;
n.ledARGB = Color.YELLOW;
n.ledOnMS = 500;
n.ledOffMS = 5000;
n.sound = Uri.parse("file:///sdcard/notif.mp3");
n.number = 3;
n.defaults |= Notification.DEFAULT_SOUND;