The import android. Support. The v4. App. NotificationCompat;
,,,,,,
Public class MainActivity extends AppCompatActivity implements the View. An OnClickListener {
@ Override
Protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
The setContentView (R.l ayout. Activity_main);
The Button sendNotice=(Button) the findViewById (R.i d.s end_notice);
SendNotice. SetOnClickListener (this);
}
Public void onClick (View v) {
The switch (v.g etId ()) {
Case R.i d.s end_notice:
Intent Intent=new Intent (this, NotificationActivity. Class);
PendingIntent PI=PendingIntent. GetActivity (this, 0, intent, PendingIntent. FLAG_UPDATE_CURRENT);
NotificationManager manager=(NotificationManager) getSystemService (NOTIFICATION_SERVICE);
NotificationCompat. Builder Builder=new NotificationCompat. Builder (this);
Notification Notification=builder. SetSmallIcon (R.m ipmap. Ic_launcher)
SetContentTitle (" this is the content title ")
SetContentText (" this is the content text ")
SetWhen (System. CurrentTimeMillis ())
. SetContentIntent (PI)
SetAutoCancel (true)
//. SetDefaults (NotificationCompat DEFAULT_ALL)
.build();
Manager. Notify (1, notification);
break;
Default:
break;
}
}
CodePudding user response:
Horizontal line is the compiler tip you this method is obsolete, you can order into method, annotation will tell you the new alternative is whatCodePudding user response:
Minimum adapter 4.4 Android developers, you now not mobile versionCodePudding user response: