通知Notification
Intent intent=new Intent(this,NotificationActivity.class);//intent开启一个活动
PendingIntent pi=PendingIntent.getActivity(this,0,intent,0);//pendingIntent是一种特殊的intent,延时Intent
NotificationManager manager= (NotificationManager)getSystemService(NOTIFICATION_SERVICE); //首先获取Notification的Manager准备管理Notification
Notification notification= new NotificationCompat.Builder(MainActivity.this).setContentTitle("这是一个通知")//通过new出NotificationCompat.Builder实例
.setStyle(new NotificationCompat.BigTextStyle().bigText("这是一个通知内容dsfdfhfadffgjgfsghghgfdsadasfghfsasdfgdfaasdfgfsaasdgfhfaasdghgfasfdgbbfgsaeaeasf").setBigContentTitle("sDA")//设置一个长文字通知
)/*.setContentText("这是一个通知内容dsfdfhfadffgjgfsghghgfdsadasfghfsasdfgdfaasdfgfsaasdgfhfaasdghgfasfdgbbfgsaeaeasf")*/
.setWhen(System.currentTimeMillis()).setSmallIcon(R.mipmap.ic_launcher
).setLargeIcon(BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher_round)
).setContentIntent(pi
)/*.第一种方法setAutoCancel(true)*/
/*.setSound(Uri.fromFile(new File("/system/media/audio/ringtones/Luna.ogg"))
).setVibrate(new long[]{0,1000,1000,1000}).setLights(Color.RED,1000,1000)
*/.setDefaults(NotificationCompat.DEFAULT_ALL).build();
manager.notify(1,notification);