publicclassNotificationActivityextendsActivity{@OverrideprotectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.activity_notification);//get a notification manager from the contextNotificationManagernotificationManager=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);//get notification object from the builder using it's contextNotificationn=newNotification.Builder(this).setContentTitle("App Started").setContentText("This is the first app").setAutoCancel(true).setSmallIcon(R.drawable.common_google_signin_btn_icon_dark).build();//push notificationnotificationManager.notify(0,n);}}
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.