Home | History | Annotate | only in /developers/build/prebuilts/gradle/BasicNotifications
Up to higher level directory
NameDateSize
.google/21-Oct-2016
Application/21-Oct-2016
build.gradle21-Oct-201611
CONTRIB.md21-Oct-20161.6K
CONTRIBUTING.md21-Oct-20161.5K
gradle/21-Oct-2016
gradlew21-Oct-20165K
gradlew.bat21-Oct-20162.3K
LICENSE21-Oct-201631.5K
packaging.yaml21-Oct-2016492
README.md21-Oct-20164K
screenshots/21-Oct-2016
settings.gradle21-Oct-201622

README.md

      1 
      2 Android BasicNotifications Sample
      3 ===================================
      4 
      5 A basic app showing how to display events in the system's notification bar using
      6 the NotificationCompat API.
      7 NotificationCompat API is used for compatibility with older devices, running Android
      8 1.6 (Donut) (API level 4) or newer.
      9 
     10 Introduction
     11 ------------
     12 
     13 The [Notification API][1] allows the app developers to display a message outside
     14 of your application's normal UI.
     15 
     16 The class [Notification][2] was added in the Android 3.0 (API level 11), but this
     17 sample refers to the [NotificationCompat][3] class (part of the [support library][4]),
     18  which offers the same functionality for Android 1.6 (API level 4) or newer.
     19 
     20 A Notificaiton can be created using Notification.Builder object.
     21 At bare minimum, a Builder object must include the following:
     22 - A small icon, set by [setSmallIcon()][5]
     23 - A title, set by [setContentTitle()][6]
     24 - Detail text, set by [setContentText()][7]
     25 
     26 in the code snippet, it looks like following.
     27 ```java
     28 NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
     29 builder.setSmallIcon(R.drawable.ic_stat_notification);
     30 builder.setContentTitle("BasicNotifications Sample");
     31 builder.setContentText("Time to learn about notifications!");
     32 ```
     33 
     34 To issue the notification, call notify() method in the [NotificationManager][8].
     35 The code snippet will immediately display the notification icon in the
     36 notification bar.
     37 
     38 ```java
     39 NotificationManager notificationManager = (NotificationManager) getSystemService(
     40         NOTIFICATION_SERVICE);
     41 notificationManager.notify(NOTIFICATION_ID, builder.build());
     42 ```
     43 
     44 [1]: http://developer.android.com/guide/topics/ui/notifiers/notifications.html
     45 [2]: http://developer.android.com/reference/android/app/Notification.html
     46 [3]: http://developer.android.com/reference/android/support/v4/app/NotificationCompat.html
     47 [4]: http://developer.android.com/tools/support-library/index.html
     48 [5]: http://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#setSmallIcon(int)
     49 [6]: http://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#setContentTitle(java.lang.CharSequence) 
     50 [7]: http://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#setContentText(java.lang.CharSequence)
     51 [8]: http://developer.android.com/reference/android/app/NotificationManager.html
     52 
     53 Pre-requisites
     54 --------------
     55 
     56 - Android SDK 24
     57 - Android Build Tools v24.0.1
     58 - Android Support Repository
     59 
     60 Screenshots
     61 -------------
     62 
     63 <img src="screenshots/main.png" height="400" alt="Screenshot"/> 
     64 
     65 Getting Started
     66 ---------------
     67 
     68 This sample uses the Gradle build system. To build this project, use the
     69 "gradlew build" command or use "Import Project" in Android Studio.
     70 
     71 Support
     72 -------
     73 
     74 - Google+ Community: https://plus.google.com/communities/105153134372062985968
     75 - Stack Overflow: http://stackoverflow.com/questions/tagged/android
     76 
     77 If you've found an error in this sample, please file an issue:
     78 https://github.com/googlesamples/android-BasicNotifications
     79 
     80 Patches are encouraged, and may be submitted by forking this project and
     81 submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.
     82 
     83 License
     84 -------
     85 
     86 Copyright 2016 The Android Open Source Project, Inc.
     87 
     88 Licensed to the Apache Software Foundation (ASF) under one or more contributor
     89 license agreements.  See the NOTICE file distributed with this work for
     90 additional information regarding copyright ownership.  The ASF licenses this
     91 file to you under the Apache License, Version 2.0 (the "License"); you may not
     92 use this file except in compliance with the License.  You may obtain a copy of
     93 the License at
     94 
     95 http://www.apache.org/licenses/LICENSE-2.0
     96 
     97 Unless required by applicable law or agreed to in writing, software
     98 distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
     99 WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
    100 License for the specific language governing permissions and limitations under
    101 the License.
    102