Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For More Information refer this <a href="http://developer.android.com/guide/topics/ui/notifiers/notifications.html">Link</a>.</p> <p>Add permission to your manifest file </p> <pre><code>&lt;uses-permission android:name="android.permission.VIBRATE"&gt;&lt;/uses-permission&gt; </code></pre> <p><strong>EDIT</strong> // 1. Get a reference to the NotificationManager</p> <pre><code>String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); </code></pre> <p>// 2. Instantiate the Notification</p> <pre><code>int icon = R.drawable.notification_icon; CharSequence tickerText = "Hello"; long when = System.currentTimeMillis(); Notification notification = new Notification(icon, tickerText, when); </code></pre> <p>// 3. Define the Notification's expanded message and Intent</p> <pre><code>Context context = getApplicationContext(); CharSequence contentTitle = "My notification"; CharSequence contentText = "Hello World!"; Intent notificationIntent = new Intent(this, MyClass.class); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); </code></pre> <p>// 4. Pass the Notification to the NotificationManager</p> <pre><code>private static final int HELLO_ID = 1; mNotificationManager.notify(HELLO_ID, notification); </code></pre> <p>// ---------------------- // Add Sound // ---------------------- // a. Default sound</p> <pre><code>notification.defaults |= Notification.DEFAULT_SOUND; </code></pre> <p>// b. Custom sound from SD card</p> <pre><code>notification.sound = Uri.parse("file:///sdcard/notification/SOUND.mp3"); </code></pre> <p>// ---------------------- // Add Vibration // ---------------------- // a. Default vibration</p> <pre><code>notification.defaults |= Notification.DEFAULT_VIBRATE; </code></pre> <p>// b. Custom vibration</p> <pre><code>long[] vibrate = {0,100,200,300}; notification.vibrate = vibrate; </code></pre> <p>// ------------------------ // Add Flashing Lights // ------------------------ // a. Default lights</p> <pre><code>notification.defaults |= Notification.DEFAULT_LIGHTS; </code></pre> <p>// b. Custom lights</p> <pre><code>notification.ledARGB = 0xff00ff00; notification.ledOnMS = 300; notification.ledOffMS = 1000; notification.flags |= Notification.FLAG_SHOW_LIGHTS; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload