title: How do i create a notification in a fragment in android
body: <p>I am trying to create a notification in a fragment. I am having errors. Can any help ?</p>
  
  <p>Here is my code</p>
  
  <pre><code>NotificationManager notification = (Notification) getSystemService(getActivity().NOTIFICATION_SERVICE);
  int icon = R.drawable.ic_launcher;
  CharSequence tickerText = "your daily tip";
  long when System.currentTimeMillis();
  Context context = getActivity();
  CharSequence contentTitle = "AutoKit";
  CharSequence = contentText = "hi";
  Intent notificationIntent = new Intent();
  PendingIntent contentIntent = PendingIntent.getActivity(getActivity(), 0, notificationIntent, 0);
  Notification notification = new Notification(icon, tickerText, when);
  notification.setLatestEventInfo(context, contextTitle, contentText, contentIntent);
  notificationManager.notify(1, notification);
  </code></pre>
  
  <p>The error lies in the first line.</p>