notifications for android l & wear

Post on 15-Jan-2015

421 Views

Category:

Education

3 Downloads

Preview:

Click to see full reader

DESCRIPTION

2014 GDG 안드로이드 컨퍼런스에서 진행된 'Notifications for Android L & wear' 세션 프리젠테이션입니다.

TRANSCRIPT

builder.setContentTitle("Private notification") .setContentText("Private notification content") .setVisibility(Notification.VISIBILITY_PRIVATE) .setColor(Color.argb(1, 204, 0, 0)) .setPublicVersion( new Notification.Builder(this) .setColor(Color.argb(1, 0, 153, 204)) .setSmallIcon(R.drawable.ic_action_web_site) .setContentText("Public version of private content") .setContentTitle("Public version") .build());

builder.setPriority(Notification.PRIORITY_HIGH) .setContentTitle("High priority") .setDefaults(Notification.DEFAULT_VIBRATE); mng.notify(1, builder.build());

PendingIntent pi = PendingIntent.getActivity(this, 0, new Intent(Intent.ACTION_VIEW).setData(Uri.parse("http://android.com")), 0); builder.setFullScreenIntent(pi, true) .setContentIntent(pi) .setContentTitle("Notification with Fullscreen Intent") .setContentText("Content text");

Notification notification = new Notification.Builder(BridgeActivity.this) .setSmallIcon(R.drawable.ic_launcher) .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.bg_wear_notes)) .setContentTitle("Android.com") .setContentText("Check out news from android.com!") .setLocalOnly(!cbBridgeNotification.isChecked()) .setAutoCancel(true) .build();

// Create wear only action PendingIntent piw = PendingIntent.getActivity(this, 0, new Intent(Intent.ACTION_VIEW).setData(Uri.parse("http://android.com/wear")), PendingIntent.FLAG_UPDATE_CURRENT); Notification.Action wearOnlyAction = new Notification.Action.Builder(R.drawable.ic_action_web_site, "Wear only", piw).build(); ! builder.extend(new Notification.WearableExtender().addAction(wearOnlyAction));

remoteInput = new RemoteInput.Builder(VoiceInputResultActivity.KEY_VOICE_INPUT) .setLabel("Say message") .setChoices(getResources().getStringArray(R.array.reply_choices)) .build(); !// 중략 !Notification.Action replyAction = new Notification.Action.Builder(R.drawable.ic_action_web_site, "Reply", pi) .addRemoteInput(remoteInput).build(); !Notification.Builder builder = new Notification.Builder(this) .setSmallIcon(R.drawable.ic_action_web_site) .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.img_gaejugi)) .setAutoCancel(true) .setContentTitle("John Doe") .setContentText("Lunch?") .extend(new Notification.WearableExtender().addAction(replyAction));

Notification.Builder builder = new Notification.Builder(this); builder.setSmallIcon(R.drawable.ic_action_web_site) //… 생략 !Notification secondPage = new Notification.Builder(this) // 생략 !Notification thirdPage = new Notification.Builder(this) // 생략 !Notification pagingNotification = new Notification.WearableExtender() .addPage(secondPage) .addPage(thirdPage) .extend(builder).build();

Notification noti1 = new Notification.Builder(this).setGroup(GROUP_MESSAGE) // 생략 !Notification noti2 = new Notification.Builder(this).setGroup(GROUP_MESSAGE) // 생략 !NotificationManager mng = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); mng.notify(0, noti1); mng.notify(1, noti2); !Notification summary = new Notification.Builder(this) // 생략 .setGroup(GROUP_MESSAGE) .setGroupSummary(true) .extend(new Notification.WearableExtender() .setBackground(BitmapFactory.decodeResource( getResources(), R.drawable.img_gaejugi))) .build(); ! mng.notify(3, summary);

top related