1 page.title= 2 page.tags=notifications 3 helpoutsWidget=true 4 page.image=/preview/images/notifications-card.png 5 6 trainingnavtop=true 7 8 @jd:body 9 10 <div id="qv-wrapper"> 11 <div id="qv"> 12 13 <!-- table of contents --> 14 <h2></h2> 15 <ol> 16 <li><a href="#direct"></a></li> 17 <li><a href="#bundle"></a></li> 18 <li><a href="#custom"></a></li> 19 </ol> 20 21 </div> 22 </div> 23 24 <p>Android N API 25 </p> 26 27 <p>Android N {@link android.support.v4.app.RemoteInput} 28 API 29 </p> 30 31 <p> 32 Android N 33 Android N {@link 34 android.support.v4.app.NotificationCompat.Builder#setGroup 35 NotificationCompat.Builder.setGroup()} 36 37 38 </p> 39 40 <p>Android N API 41 API 42 43 </p> 44 45 <p> 46 </p> 47 48 <h2 id="direct"></h2> 49 50 <p> Android N 51 52 53 54 55 56 57 58 59 <img id="fig-reply-button" src="{@docRoot}preview/images/inline-reply.png" srcset="{@docRoot}preview/images/inline-reply.png 1x, 60 {@docRoot}preview/images/inline-reply_2x.png 2x" width="400"> 61 <p class="img-caption"> 62 <strong> 1.</strong> Android N <strong></strong> 63 . 64 </p> 65 66 <h3></h3> 67 68 <p> 69 </p> 70 71 <ol> 72 <li> {@link android.support.v4.app.RemoteInput.Builder} 73 74 75 76 77 78 <pre> 79 // Key for the string that's delivered in the action's intent 80 private static final String KEY_TEXT_REPLY = "key_text_reply"; 81 String replyLabel = getResources().getString(R.string.reply_label); 82 RemoteInput remoteInput = new RemoteInput.Builder(KEY_TEXT_REPLY) 83 .setLabel(replyLabel) 84 .build(); 85 </pre> 86 </li> 87 <li> <code>addRemoteInput()</code> {@link android.support.v4.app.RemoteInput} 88 89 90 <pre> 91 // Create the reply action and add the remote input 92 Notification.Action action = 93 new Notification.Action.Builder(R.drawable.ic_reply_icon, 94 getString(R.string.label), replyPendingIntent) 95 .addRemoteInput(remoteInput) 96 .build(); 97 </pre> 98 </li> 99 100 <li> 101 102 <pre> 103 // Build the notification and add the action 104 Notification notification = 105 new Notification.Builder(mContext) 106 .setSmallIcon(R.drawable.ic_message) 107 .setContentTitle(getString(R.string.title)) 108 .setContentText(getString(R.string.content)) 109 .addAction(action)) 110 .build(); 111 112 // Issue the notification 113 NotificationManager notificationManager = 114 NotificationManager.from(mContext); 115 notificationManager.notify(notificationId, notification); 116 117 </pre> 118 </li> 119 120 </ol> 121 122 123 <p> 124 </p> 125 126 <img id="fig-user-input" src="{@docRoot}preview/images/inline-type-reply.png" srcset="{@docRoot}preview/images/inline-type-reply.png 1x, 127 {@docRoot}preview/images/inline-type-reply_2x.png 2x" width="300"> 128 <p class="img-caption"> 129 <strong> 2.</strong> 130 </p> 131 132 <h3></h3> 133 134 <p> 135 </p> 136 <ol> 137 <li> {@link android.support.v4.app.RemoteInput#getResultsFromIntent 138 getResultsFromIntent()} 139 {@link android.os.Bundle} 140 141 </li> 142 143 <pre> 144 Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); 145 </pre> 146 147 <li> ( {@link 148 android.support.v4.app.RemoteInput.Builder} ) 149 </li> 150 </ol> 151 152 <p> 153 </p> 154 155 <pre> 156 // Obtain the intent that started this activity by calling 157 // Activity.getIntent() and pass it into this method to 158 // get the associated string. 159 160 private CharSequence getMessageText(Intent intent) { 161 Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); 162 if (remoteInput != null) { 163 return remoteInput.getCharSequence(KEY_TEXT_REPLY); 164 } 165 return null; 166 } 167 </pre> 168 169 <p> () () {@link android.support.v4.app.RemoteInput} {@code setRemoteInputHistory()} 170 171 172 173 174 175 176 </p> 177 178 <h2 id="bundle"></h2> 179 180 <p>Android N 181 <i></i> Android Wear 182 <a href="{@docRoot}training/wearables/notifications/stacks.html"></a> 183 184 185 {@link android.support.v4.app.NotificationCompat.Builder#setGroup 186 Builder.setGroup()} 187 </p> 188 189 <p> 190 191 192 193 194 195 196 197 </p> 198 199 <img id="fig-bundles" src="{@docRoot}preview/images/bundles.png" srcset="{@docRoot}preview/images/bundles.png 1x, 200 {@docRoot}preview/images/bundles_2x.png 2x" width="300"> 201 <p class="img-caption"> 202 <strong> 3.</strong> 203 204 </p> 205 206 <p><a href="{@docRoot}training/wearables/notifications/stacks.html#AddGroup"></a> 207 208 </p> 209 210 211 <h3 id="best-practices"></h3> 212 <p> Android {@link android.app.Notification.InboxStyle InboxStyle} 213 214 215 </p> 216 217 <h3></h3> 218 219 <p> 220 </p> 221 222 <ul> 223 <li> 224 </li> 225 <li> 226 227 </li> 228 <ul> 229 <li></li> 230 <li></li> 231 </ul> 232 </ul> 233 234 <p> 235 236 </p> 237 238 <p> 239 240 241 242 ({@link android.app.Notification.InboxStyle InboxStyle} 243 {@link android.app.Notification.BigTextStyle BigTextStyle}) 244 245 </p> 246 247 <h3 id ="post"></h3> 248 249 <p> 250 251 252 253 254 255 </p> 256 257 <p class="note"> 258 <strong></strong> Android N 259 Android N 260 261 </p> 262 263 <h3></h3> 264 265 <p><a href="{@docRoot}guide/topics/ui/notifiers/notifications.html#Heads-up"></a> 266 267 268 269 270 </p> 271 272 273 <h3></h3> 274 275 <p> 276 Android 5.0 (API 21) Android Wear {@link 277 android.app.Notification} API 278 API {@code 279 setRemoteInputHistory()} 280 281 282 </p> 283 284 <p> 285 API {@link android.support.v4.app.NotificationCompat} 286 Android 287 288 289 290 Android 291 Wear API 292 293 294 </p> 295 296 <h2 id="custom"> </h2> 297 <p> Android N 298 299 </p> 300 301 <p>Android N API 302 </p> 303 304 <dl> 305 <dt> 306 {@code DecoratedCustomViewStyle()}</dt> 307 <dd> 308 </dd> 309 <dt> 310 {@code DecoratedMediaCustomViewStyle()}</dt> 311 <dd> </dd> 312 </dl> 313 314 <p> API {@code setStyle()} 315 </p> 316 317 <p> 318 {@code DecoratedCustomViewStyle()} </p> 319 320 <pre> 321 Notification noti = new Notification.Builder() 322 .setSmallIcon(R.drawable.ic_stat_player) 323 .setLargeIcon(albumArtBitmap)) 324 .setCustomContentView(contentView); 325 .setStyle(new Notification.DecoratedCustomViewStyle()) 326 .build(); 327 328 </pre> 329