Notification in Android L:
In L, notifications receive an important structural visual and functional update:- Visual changes to notifications as part of material design
- Notifications are now available on the device lock screen, yet sensitive content can still be hidden behind it
- A new presentation format called Heads-up for receiving high priority notifications while using the device
- Cloud-synced notifications - act on a notification on your Android tablet and it is also dismissed on your phone.
- And starting now (in Android 4.4W, API Level 20, the platform release for Android Wear), your notifications will bridge to Android Wear devices. You can extend the functionality of notifications on Wear in two different ways. First, you can add speech input and canned responses to Actions on Wear, allowing users to complete tasks from their wrists. Second, you can write Wear apps that hook into your notifications to go even further in terms of creating interactive experiences for users.
For more information of notifications ref android notifications.
Sample Code for showing notification
/**
* Send a sample notification using the NotificationCompat API.
*/
public void sendNotification(View view) {
Intent intent = new Intent(
Intent.ACTION_VIEW,
Uri.parse("http://developer.android.com/reference/android/app/Notification.html"));
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
intent, 0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(
this);
builder.setSmallIcon(R.drawable.ic_stat_notification);
// Set the intent that will fire when the user taps the notification.
builder.setContentIntent(pendingIntent);
builder.setAutoCancel(true);
builder.setLargeIcon(BitmapFactory.decodeResource(getResources(),
R.drawable.ic_launcher));
builder.setContentTitle("BasicNotifications Sample");
builder.setContentText("Time to learn about notifications!");
builder.setSubText("Tap to view documentation about notifications.");
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(NOTIFICATION_ID, builder.build());
}
Output:
In first pic, we can see the notification received in the status bar.
On drag of screen from top. We can see, how the basic notification appears.
No comments :
Post a Comment