java - press a button and show notification -


I have a button in XML, it does not make a notification which has an error (notification code is following, click on should show. builder (undefined new View.OnClickListener () {})) anyone tell what the problem

Mainactivity.Java

  package com.example.auto; Public class increases main activity activity {@ Override Protected Zero to Create (Bundle Saved Instantstate) {Super.New (Saved Instantstate); SetContentView (R.layout.activity_main); Button B = (button) Find VVBIID (R.B. button 1); b.setOnClickListener (New OnClickListener () {@Override public void onClick (View v) {Intent intent = new Intent (MainActivity.this, NotificationReceiver.class); PendingIntent pIntent = PendingIntent.getActivity (MainActivity.this, 0, intentions, 0 ); notification mNotification = new Notification.Builder (it) .setContentTitle ( "! new Post") .setContentText ( "! here is an awesome update for you") .setContentIntent (pIntent) .addAction (0, "View" pIntent) .addAction (0, "Remind that", pIntent) .build (); notificationManager notificationManager = (notificationManager) getSystemService (NOTIFICATION_SERVICE); notificationManager.notify (0, mNotification);}}); }}  

try it :)

  NotificationCompat .Builder mBuilder = new NotificationCompat.Builder (reference) .setSmallIcon (R.drawable.ic_launcher) .setContentTitle ( "My notifications") .setContentText ( "Hello World!"); // Creates a clear intention for an activity in your app that means the result = new intent (getApplicationContext (), MYDEMOACTIVITY.class); // Stack Builder object will include an artificial back stack // current activity // It ensures that navigating backward by activity reaches the home screen from your computer Task StackBuilder StackBuilder = Task StackBuilder.Sent (reference); // Add the stack back to the intent (but do not intend to yourself) stackBuilder.addParentStack (MYDEMOACTIVITY.class); // Stack Stack Bailer adds the intent to start activity on top. AddNextIntent (as a result); Pending prominent result padding = stackBuilder.getPendingIntent (0, pending INNT.FLAG_UPDATE_CURRENT); MBuilder.setContentIntent (resultPendingIntent); Notification Manager Account Manager = (Notification Manager) getSystemService (reference .NETIFICATION_SERVICE); // MID allows you to update the information later on. MNotificationManager.notify (MID, Mbuilder Build ());  

Comments