标签:text ack family div ring ble log 参数 cancel
//创建 NotificationManager 实例
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notification = new NotificationCompat.Builder(this)
.setContentTitle("This is title") //标题
.setContentText("This is content") //正文内容
.setWhen(System.currentTimeMillis()) //通知被创建的时间
.setSmallIcon(R.mipmap.ic_launcher) //状态栏通知图标
//通知界面的图标
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher))
.build();manager.notify(1, notification);//发送通知
Intent intent =new Intent(this,NotificationActivity.class);
//指定意图
PendingIntent pi=PendingIntent.getActivity(this,0,intent,0);
.setContentIntent(pi)
.setAutoCancel(true)
NotificationManager manger=(NotificationManager)getSystemService(
NOTIFICATION_SERVICE);
manger.cancel(1);
//设置声音 路径:是系统的内置铃声目录
.setSound( Uri.fromFile(new File("/system/media/audio/ringtones/ANDROMEDA.ogg")))
<uses-permission android:name="android.permission.VIBRATE"/>
//设置震动 静止,震动,静止, 震动。。。。。
.setVibrate(new long[]{0, 1000, 1000, 1000})
//设置灯光 颜色 亮的时间 暗的时间
.setLights(Color.RED,300, 300)
builder.setDefaults(NotificationCompat.DEFAULT_ALL);
// 长文字显示
builder.setStyle(new NotificationCompat.BigTextStyle().bigText("" +
"111111111111111111111222222222222222222222223333333333333333333" +
"4444444444444444444444444444445555555555555555555555555555555" +
"666666666666666666666666666666"));
// 图片上显示 ,注意图片不能太大
builder.setStyle(new NotificationCompat.BigPictureStyle().bigPicture
(BitmapFactory.decodeResource(getResources(),R.drawable.google)));
标签:text ack family div ring ble log 参数 cancel
原文地址:http://www.cnblogs.com/-Tiger/p/7157656.html