Home | History | Annotate | only in /developers/build/prebuilts/gradle/BasicNotifications
Up to higher level directory
NameDateSize
.google/23-Apr-2015
Application/23-Apr-2015
build.gradle23-Apr-201511
CONTRIB.md23-Apr-20151.6K
CONTRIBUTING.md23-Apr-20151.5K
gradle/23-Apr-2015
gradlew23-Apr-20155K
gradlew.bat23-Apr-20152.3K
LICENSE23-Apr-201511.1K
NOTICE23-Apr-2015613
packaging.yaml23-Apr-2015492
README.md23-Apr-20154K
screenshots/23-Apr-2015
settings.gradle23-Apr-201522

README.md

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