title: Create Notification App in Android?
body: <p>I want to create a sample project to show notification on click of button then when the user selects it open that activity in my app or open a url on selection of that. I have done something but I'm unable to complete the functionality.</p>
  
  <p>First I am getting error to use this: <code>@SuppressLint("NewApi")</code></p>
  
  <p>If I am not using this I am getting the error on here </p>
  
  <pre><code>Notification noti = new Notification.Builder(this)
  </code></pre>
  
  <p><strong>Activity Code</strong>  </p>
  
  <pre><code>public class NotificationExample extends Activity implements OnClickListener{
  
      private Button b;
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_notification_example);
          b=(Button)findViewById(R.id.button1);
          b.setOnClickListener(this);
  
      }
  
  
      @SuppressLint("NewApi")
      @Override
      public void onClick(View v) {
          Intent intent = new Intent();
          PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
          Notification noti = new Notification.Builder(this)
          .setTicker("Ticker Title")
          .setContentTitle("Content Title")
          .setContentText("Notification content.")
          .setSmallIcon(R.drawable.ic_launcher)
          .setContentIntent(pIntent).getNotification();
          noti.flags=Notification.FLAG_AUTO_CANCEL;
          NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
          notificationManager.notify(0, noti); 
      }
  }
  </code></pre>
  
  <p>Why I have to use this: </p>
  
  <pre><code>`@SuppressLint("NewApi")` 
  </code></pre>
  
  <p>in my code?
  I am not getting the notification sound. Please suggest me what changes I have to make in my code.</p>