Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have created the class to show notifications:</p> <pre><code>public class NotificationData { public static NotificationManager mNotificationManager; public static int SIMPLE_NOTFICATION_ID; private Context _context; public NotificationData(Context context) { _context = context; } public void clearNotification() { mNotificationManager.cancel(SIMPLE_NOTFICATION_ID); } public void SetNotification(int drawable, String msg, String action_string, Class cls) { mNotificationManager = (NotificationManager) _context.getSystemService(Context.NOTIFICATION_SERVICE); final Notification notifyDetails = new Notification(drawable, "Post Timer", System.currentTimeMillis()); long[] vibrate = { 100, 100, 200, 300 }; notifyDetails.vibrate = vibrate; notifyDetails.ledARGB = 0xff00ff00; notifyDetails.ledOnMS = 300; notifyDetails.ledOffMS = 1000; // notifyDetails.number=4; notifyDetails.defaults =Notification.DEFAULT_ALL; Context context = _context; CharSequence contentTitle = msg; CharSequence contentText = action_string; Intent notifyIntent = new Intent(context, cls); // Bundle bundle = new Bundle(); // bundle.putBoolean(AppConfig.IS_NOTIFICATION, true); notifyIntent.putExtras(bundle); PendingIntent intent = PendingIntent.getActivity(_context, 0,notifyIntent, android.content.Intent.FLAG_ACTIVITY_NEW_TASK); notifyDetails.setLatestEventInfo(context, contentTitle, contentText, intent); mNotificationManager.notify(SIMPLE_NOTFICATION_ID, notifyDetails); } } </code></pre> <p>How to use this class:</p> <pre><code>NotificationData notification; //create object notification = new NotificationData(this); notification.SetNotification(R.drawable.notification, "Notification Title", "Click to open", YourClassName.class); </code></pre> <p>Add permission <code>android.permission.VIBRATE</code></p>
    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. 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.
 

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