1 page.title= 2 page.tags="notifications","design","L" 3 @jd:body 4 5 <a class="notice-developers" href="{@docRoot}training/notify-user/index.html"> 6 <div> 7 <h3> </h3> 8 <p> </p> 9 </div> 10 </a> 11 12 <a class="notice-designers" href="notifications_k.html"> 13 <div> 14 <h3> Android 4.4 </h3> 15 </div> 16 </a> 17 18 <!-- video box --> 19 <a class="notice-developers-video" href="https://www.youtube.com/watch?v=Uiq2kZ2JHVY"> 20 <div> 21 <h3></h3> 22 <p>DevBytes: Android L Developer Preview</p> 23 </div> 24 </a> 25 26 <style> 27 .col-5, .col-6, .col-7 { 28 margin-left:0px; 29 } 30 </style> 31 32 <p> 33 34 , . 35 , 36 37 , , , 38 , Android .</p> 39 40 <h4 id="New"><strong> Android 5.0</strong></h4> 41 42 <p> Android 5.0 , 43 , :</p> 44 45 <ul> 46 <li> 47 Material Design;</li> 48 <li> , 49 - 50 ;</li> 51 <li> , , 52 Heads-up;</li> 53 <li> : 54 Android, 55 .</li> 56 </ul> 57 58 <p class="note"><strong>.</strong> 59 Android 60 . 61 <a href="./notifications_k.html"> Android 4.4 </a>.</p> 62 63 <h2 id="Anatomy"> </h2> 64 65 <p> 66 .</p> 67 68 <h3 id="BaseLayout"> </h3> 69 70 <p> , , , .</p> 71 72 <ul> 73 <li> <strong></strong> . 74 . 75 , 76 .</li> 77 <li> <strong></strong> 78 <strong></strong>.</li> 79 <li> <strong> </strong>.</li> 80 </ul> 81 82 <p>, {@link android.app.Notification.Builder Notification.Builder} 83 , Android 84 5.0 , , , 85 . 86 Android 87 <a href="./notifications_k.html"> Android 4.4 </a>.</p></p> 88 89 90 <img style="margin:20px 0 0 0" src="{@docRoot}images/android-5.0/notifications/basic_combo.png" alt="" width="700px" /> 91 92 93 <div style="clear:both;margin-top:20px"> 94 <p class="img-caption"> 95 () () 96 97 </p> 98 </div> 99 100 <h3 id="ExpandedLayouts"> </h3> 101 102 103 <p> , 104 . 105 . 106 107 ,— ,— 108 . 109 , / 110 . 111 Android 112 113 (, ). 114 () 115 ().</p> 116 117 <img style="margin-top:30px" 118 src="{@docRoot}images/android-5.0/notifications/expandedtext_combo.png" 119 alt="" width="700px" height;="284px" /> 120 <img style="margin-top:30px" 121 src="{@docRoot}images/android-5.0/notifications/stack_combo.png" 122 alt="" width="700px" height;="284px" /> 123 <img style="margin-top:30px" 124 src="{@docRoot}images/android-5.0/notifications/ExpandedImage.png" 125 alt="" width="311px" height;="450px" /> 126 127 <h3 id="actions" style="clear:both; margin-top:40px"></h3> 128 129 <p>Android , 130 . 131 , 132 , , 133 . 134 , " , ", 135 .</p> 136 137 138 <img src="{@docRoot}images/android-5.0/notifications/action_combo.png" alt="" width="700px" /> 139 140 141 142 <p style="clear:both"> 143 . 144 , . 145 146 , 147 .</p> 148 149 <p> </p> 150 151 <ul> 152 <li> , 153 ; 154 <li> . 155 </ul> 156 157 <p> </p> 158 159 <ul> 160 <li> ; 161 <li> , (, "" 162 ""). 163 </ul> 164 165 166 167 <p> , 168 . 169 , 170 171 . 172 173 , , , 174 175 , 176 .</p> 177 178 <h2 style="clear:left"> heads-up</h2> 179 <div class="figure" style="width:311px"> 180 <img src="{@docRoot}images/android-5.0/notifications/hun-example.png" alt="" width="311px" /> 181 <p class="img-caption"> 182 heads-up ( , ), 183 184 185 </p> 186 </div> 187 188 <p> (. ), 189 190 , .</p> 191 <p> 192 . , <a href="#correctly_set_and_manage_notification_priority"></a> 193 , heads-up.</p> 194 195 <p><b> heads-up </b></p> 196 197 <ul> 198 <li> , ;</li> 199 <li> ;</li> 200 <li> SMS-;</li> 201 <li> .</li> 202 </ul> 203 204 <h2 style="clear:both" id="guidelines"> </h2> 205 206 207 <h3 id="MakeItPersonal"> </h3> 208 209 <p> , (, 210 ), , 211 {@link android.app.Notification.Builder#setLargeIcon setLargeIcon()}. , 212 (. {@link android.app.Notification#EXTRA_PEOPLE}).</p> 213 214 <p> - , 215 216 .</p> 217 218 219 <img src="{@docRoot}images/android-5.0/notifications/Triggered.png" alt="" width="311px" /> 220 <p style="margin-top:10px" class="img-caption"> 221 , -, . 222 </p> 223 224 225 <h3 id="navigate_to_the_right_place"> </h3> 226 227 <p> ( 228 ), , 229 , , 230 . , , , 231 232 , . 233 - , , , 234 "" . 235 <em> </em> 236 <a href="{@docRoot}design/patterns/navigation.html#into-your-app"></a>.</p> 237 238 <h3 id="correctly_set_and_manage_notification_priority"> 239 240 </h3> 241 242 <p>Android . 243 244 , 245 . 246 247 :</p> 248 <table> 249 <tr> 250 <td class="tab0"> 251 <p><strong></strong></p> 252 </td> 253 <td class="tab0"> 254 <p><strong></strong></p> 255 </td> 256 </tr> 257 <tr> 258 <td class="tab1"> 259 <p><code>MAX</code></p> 260 </td> 261 <td class="tab1"> 262 <p> , 263 , 264 , , 265 .</p> 266 </td> 267 </tr> 268 <tr> 269 <td class="tab1"> 270 <p><code>HIGH</code></p> 271 </td> 272 <td class="tab1"> 273 <p>, , , , 274 , . 275 heads-up.</p> 276 </td> 277 </tr> 278 <tr> 279 <td class="tab1"> 280 <p><code>DEFAULT</code></p> 281 </td> 282 <td class="tab1"> 283 <p> , .</p> 284 </td> 285 </tr> 286 <tr> 287 <td class="tab1"> 288 <p><code>LOW</code></p> 289 </td> 290 <td class="tab1"> 291 <p> , , 292 . , 293 294 , . , 295 , 296 297 .</p> 298 </td> 299 </tr> 300 <tr> 301 <td class="tab1"> 302 <p><code>MIN</code></p> 303 </td> 304 <td class="tab1"> 305 <p> , , , , 306 . 307 . 308 .</p> 309 </td> 310 </tr> 311 </table> 312 313 314 <h4 id="how_to_choose_an_appropriate_priority"><strong> 315 316 </strong></h4> 317 318 <p> <code>DEFAULT</code>, <code>HIGH</code> <code>MAX</code> , 319 320 . , 321 ,</p> 322 323 <ul> 324 <li> ;</li> 325 <li> ;</li> 326 <li> .</li> 327 </ul> 328 329 <p> <code>LOW</code> <code>MIN</code> 330 . , , 331 , , , , 332 , 333 . <code>LOW</code> <code>MIN</code> 334 ,</p> 335 336 <ul> 337 <li> ;</li> 338 <li> ;</li> 339 <li> , , 340 .</li> 341 </ul> 342 343 344 <img src="{@docRoot}images/android-5.0/notifications/notifications_pattern_priority.png" alt="" width="700" /> 345 346 347 <h3 style="clear:both" id="set_a_notification_category"> 348 </h3> 349 350 <p> (. 351 ), 352 . , , ( 353 - 354 ) .</p> 355 <table> 356 <tr> 357 <td> 358 <p><code><a 359 href="/reference/android/app/Notification.html#CATEGORY_CALL">CATEGORY_CALL</a></code></p> 360 </td> 361 <td> 362 <p> ( ) 363 </p> 364 </td> 365 </tr> 366 <tr> 367 <td> 368 <p><code><a 369 href="/reference/android/app/Notification.html#CATEGORY_MESSAGE">CATEGORY_MESSAGE</a></code></p> 370 </td> 371 <td> 372 <p> (SMS-, ..)</p> 373 </td> 374 </tr> 375 <tr> 376 <td> 377 <p><code><a 378 href="/reference/android/app/Notification.html#CATEGORY_EMAIL">CATEGORY_EMAIL</a></code></p> 379 </td> 380 <td> 381 <p> ( )</p> 382 </td> 383 </tr> 384 <tr> 385 <td> 386 <p><code><a 387 href="/reference/android/app/Notification.html#CATEGORY_EVENT">CATEGORY_EVENT</a></code></p> 388 </td> 389 <td> 390 <p> </p> 391 </td> 392 </tr> 393 <tr> 394 <td> 395 <p><code><a 396 href="/reference/android/app/Notification.html#CATEGORY_PROMO">CATEGORY_PROMO</a></code></p> 397 </td> 398 <td> 399 <p> </p> 400 </td> 401 </tr> 402 <tr> 403 <td> 404 <p><code><a 405 href="/reference/android/app/Notification.html#CATEGORY_ALARM">CATEGORY_ALARM</a></code></p> 406 </td> 407 <td> 408 <p> </p> 409 </td> 410 </tr> 411 <tr> 412 <td> 413 <p><code><a 414 href="/reference/android/app/Notification.html#CATEGORY_PROGRESS">CATEGORY_PROGRESS</a></code></p> 415 </td> 416 <td> 417 <p> </p> 418 </td> 419 </tr> 420 <tr> 421 <td> 422 <p><code><a 423 href="/reference/android/app/Notification.html#CATEGORY_SOCIAL">CATEGORY_SOCIAL</a></code></p> 424 </td> 425 <td> 426 <p>, </p> 427 </td> 428 </tr> 429 <tr> 430 <td> 431 <p><code><a 432 href="/reference/android/app/Notification.html#CATEGORY_ERROR">CATEGORY_ERROR</a></code></p> 433 </td> 434 <td> 435 <p> </p> 436 </td> 437 </tr> 438 <tr> 439 <td> 440 <p><code><a 441 href="/reference/android/app/Notification.html#CATEGORY_TRANSPORT">CATEGORY_TRANSPORT</a></code></p> 442 </td> 443 <td> 444 <p> </p> 445 </td> 446 </tr> 447 <tr> 448 <td> 449 <p><code><a 450 href="/reference/android/app/Notification.html#CATEGORY_SYSTEM">CATEGORY_SYSTEM</a></code></p> 451 </td> 452 <td> 453 <p> . .</p> 454 </td> 455 </tr> 456 <tr> 457 <td> 458 <p><code><a 459 href="/reference/android/app/Notification.html#CATEGORY_SERVICE">CATEGORY_SERVICE</a></code></p> 460 </td> 461 <td> 462 <p> </p> 463 </td> 464 </tr> 465 <tr> 466 <td> 467 <p><code><a 468 href="/reference/android/app/Notification.html#CATEGORY_RECOMMENDATION">CATEGORY_RECOMMENDATION</a></code></p> 469 </td> 470 <td> 471 <p> . , 472 473 , .</p> 474 </td> 475 </tr> 476 <tr> 477 <td> 478 <p><code><a 479 href="/reference/android/app/Notification.html#CATEGORY_STATUS">CATEGORY_STATUS</a></code></p> 480 </td> 481 <td> 482 <p> </p> 483 </td> 484 </tr> 485 </table> 486 487 <h3 id="summarize_your_notifications"> </h3> 488 489 <p> 490 , . 491 .</p> 492 493 <p> 494 , 495 .</p> 496 497 <div class="col-6"> 498 499 <p><strong></strong></p> 500 <img src="{@docRoot}images/android-5.0/notifications/Summarise_Dont.png" alt="" width="311px" /> 501 </div> 502 503 <div> 504 <p><strong></strong></p> 505 506 <img src="{@docRoot}images/android-5.0/notifications/Summarise_Do.png" alt="" width="311px" /> 507 </div> 508 509 <p style="clear:left; padding-top:30px; padding-bottom:20px"> 510 , 511 , . 512 , 513 , , 514 515 .</p> 516 <div class="col-6"> 517 <img src="{@docRoot}images/android-5.0/notifications/Stack.png" style="margin-bottom:20px" alt="" width="311px" /> 518 <p class="img-caption"> 519 ( <code>InboxStyle</code>) 520 </p> 521 </div> 522 523 <h3 style="clear:both" id="make_notifications_optional"> 524 </h3> 525 526 <p> . 527 , , 528 , 529 . 530 .</p> 531 532 <h3 id="use_distinct_icons"> </h3> 533 <p> , 534 535 .</p> 536 537 <div class="figure"> 538 <img src="{@docRoot}images/android-5.0/notifications/ProductIcons.png" alt="" width="420" /> 539 </div> 540 541 <div><p><strong></strong></p> 542 <p> Android 543 , 544 .</p> 545 546 <p><strong></strong></p> 547 <p> <a href="/design/style/iconography.html#notification"> </a> 548 , 549 <a href="/design/style/iconography.html#action-bar"> 550 </a> Material Light 551 .</p> 552 <p ><strong></strong></p> 553 <p > , 554 .</p> 555 556 <div><p><strong></strong></p> 557 <p> - 558 ( /). 559 , , Android 560 ( , 561 -), , , 562 .</p> 563 564 </div> 565 <p style="clear:both"><strong></strong></p> 566 567 <p> , . 568 .</p> 569 570 571 <h3 id="pulse_the_notification_led_appropriately"> 572 </h3> 573 574 <p> Android , 575 576 , . <code>MAX</code>, 577 <code>HIGH</code> <code>DEFAULT</code> 578 , (<code>LOW</code> 579 <code>MIN</code>) .</p> 580 581 <p> . 582 DEFAULT_LIGHTS, 583 . 584 , 585 .</p> 586 587 <h2 id="building_notifications_that_users_care_about"> , 588 </h2> 589 590 <p> , 591 . 592 . 593 . 594 , 595 596 . .</p> 597 598 <h3 id="when_to_display_a_notification">, </h3> 599 600 <p> , , 601 , 602 , . 603 Android 604 , . 605 606 , 607 . 608 , , , 609 . 610 611 <code>LOW</code> <code>MIN</code>, 612 613 .</p> 614 615 <img src="{@docRoot}images/android-5.0/notifications/TimeSensitive.png" alt="" width="311px" /> 616 <p style="margin-top:10px" class="img-caption"> 617 , 618 </p> 619 620 <p> , , 621 , .</p> 622 623 <p> <strong>, </strong>, 624 <strong> </strong>. , 625 626 , 627 . , 628 629 , 630 .</p> 631 632 <h3 style="clear:both" id="when_not_to_display_a_notification">, 633 </h3> 634 635 <div class="figure" style="margin-top:60px"> 636 <img src="{@docRoot}images/android-5.0/notifications/AntiSample1.png" alt="" width="311px" /> 637 </div> 638 639 <p> .</p> 640 641 <ul> 642 <li> , 643 , 644 . , 645 , 646 , , 647 . , 648 , .</li> 649 <li> , 650 . 651 , 652 . 653 , - , 654 .</li> 655 <li> , 656 , 657 .</li> 658 <li> , , 659 , 660 .</li> 661 <li> , 662 663 . , . 664 665 .</li> 666 <li> , 667 . 668 . 669 670 671 672 , , 673 .</li> 674 </ul> 675 676 <h2 style="clear:left" id="interacting_with_notifications"> 677 </h2> 678 679 <p> . , 680 681 .</p> 682 683 <p> , , 684 . 685 , .</p> 686 687 <h3 id="ongoing_notifications"> </h3> 688 <div class="figure" style="width:311px"> 689 <img src="{@docRoot}images/android-5.0/notifications/MusicPlayback.png" alt="" width="311px" /> 690 <p class="img-caption"> 691 692 </p> 693 </div> 694 <p> 695 . 696 , , 697 , 698 , . , 699 700 , . 701 .</p> 702 703 <h3 id="ongoing_notifications"> </h3> 704 <p> Android 5.0 705 {@link android.media.RemoteControlClient}. <em></em> , 706 707 . 708 , 709 , . , 710 , .</p> 711 712 <h3 style="clear:both" 713 id="dialogs_and_toasts_are_for_feedback_not_notification"> 714 </h3> 715 716 <p>, , 717 . 718 719 . 720 . 721 <a href="/design/patterns/confirming-acknowledging.html"> </a>.</p> 722 723 <h3> </h3> 724 725 <p> , 726 . 727 728 <a href="#correctly_set_and_manage_notification_priority"></a>, .</p> 729 730 <p> 731 732 , . , 733 734 . 735 Android 736 , </p> 737 738 <ul> 739 <li> , ;</li> 740 <li> , 741 ( , 742 , , 743 , 744 , );</li> 745 <li> , {@link android.app.Notification#EXTRA_PEOPLE}, 746 , , .</li> 747 </ul> 748 749 <p> , 750 751 , .</p> 752 753 <img src="{@docRoot}images/android-5.0/notifications/AntiSample3.png" alt="" width="700px" /> 754 755 <p class="img-caption" style="margin-top:10px"> Gmail 756 DEFAULT, 757 , Hangouts, 758 759 , . 760 </p> 761 762 763 <h3> </h3> 764 765 <p> , 766 767 . , 768 769 , .</p> 770 771 <ul> 772 <li> , ( PIN-, ), 773 . 774 , . "" 775 , .</li> 776 </ul> 777 778 <h3> , </h3> 779 <div class="figure" style="width:311px"> 780 <img src="{@docRoot}images/android-5.0/notifications/LockScreen@2x.png" srcset="{@docRoot}images/android-5.0/notifications/LockScreen.png 1x" alt="" width="311px" /> 781 <p class="img-caption"> 782 , , . 783 </p> 784 </div> 785 786 <p> , 787 . 788 <em> </em> , , 789 .</p> 790 <p> , 791 <code><a 792 href="/reference/android/app/Notification.Builder.html#setVisibility(int)">Notification.Builder.setVisibility()</a></code> 793 :</p> 794 795 <ul> 796 <li><code><a 797 href="/reference/android/app/Notification.html#VISIBILITY_PUBLIC">VISIBILITY_PUBLIC</a></code>. 798 . 799 , .</li> 800 <li><code><a 801 href="/reference/android/app/Notification.html#VISIBILITY_PRIVATE">VISIBILITY_PRIVATE</a></code>. 802 , 803 , . . 804 . 805 <ul> 806 <li> , 807 , 808 Notification <code><a 809 href="/reference/android/app/Notification.html#publicVersion">Notification.publicVersion</a></code>. 810 811 <li> "" 812 , , . 813 SMS-. SMS- . 814 <code>VISIBILITY_PRIVATE</code>, <code>publicVersion</code> 815 , , "3 ", 816 . 817 </ul> 818 </li> 819 <li><code><a 820 href="/reference/android/app/Notification.html#VISIBILITY_SECRET">Notification.VISIBILITY_SECRET</a></code>. , 821 .</li> 822 </ul> 823 <h2 style="clear:both" id="notifications_on_android_wear"> 824 Android Wear</h2> 825 826 <p> <em></em> . 827 , 828 , 829 . . 830 831 , , 832 , 833 , Android Wear, 834 835 .</p> 836 837 <h4> </h4> 838 839 <p> , , , , 840 . , 841 .</p> 842 843 <p><strong></strong></p> 844 845 <ul> 846 <li> ;</li> 847 <li> , , , "+1", "", "".</li> 848 </ul> 849 850 <img src="{@docRoot}images/android-5.0/notifications/WearBasic.png" width="156px" height="156px" alt="" /> 851 852 <p><strong> </strong></p> 853 854 <ul> 855 <li> ;</li> 856 <li> , , .</li> 857 </ul> 858 859 860 861 <p><h4> , </h4></p> 862 863 <p> , :</p> 864 865 <ul> 866 <li> , , " "</li> 867 <li> " ";</li> 868 <li> "" "", ;</li> 869 <li> , , Android Wear.</li> 870 </ul> 871 872 <img src="{@docRoot}images/android-5.0/notifications/ReplyAction.png" width="156px" height="156px" alt="" /> 873