码迷,mamicode.com
首页 > 其他好文 > 详细

光播的一些属性设置

时间:2015-12-28 16:52:28      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:

public class LocalReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent iii) {
//活动Activity(5秒)一般不要做超过5秒,广播BroadcastReceiver都是主线程(10秒),Service服务相当于子线程
//所以广播此处如果做耗时操作,一般会开启服务
// Intent intent2 = new Intent(context,MyService.class);


//在Activity里面所有直接写出来的方法,比如getSystemService(WINDOW_SERVICE),findViewById(),全部要加上context.getSystemService(Context.WINDOW_SERVICE)
// MainActivity ma = (MainActivity)context;
// Log.i("接收的数据:", intent.getStringExtra("args"));
// Toast.makeText(context, "接收本地广播", Toast.LENGTH_SHORT).show();

NotificationManager manager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);

//延迟Intent
Intent intent = new Intent(context,ShowActivity.class);
PendingIntent pi = PendingIntent.getActivity(context, 0, intent, 0);//PendingIntent.

RemoteViews rViews = new RemoteViews(context.getPackageName(), R.layout.vedio);
rViews.setImageViewResource(R.id.iv, R.drawable.title);//修改图片(那个控件,什么内容)
rViews.setTextViewText(R.id.tv, "我改了我改了");//修改文字
// 通知的使用
// Builder builder = new Notification.Builder(context);
// Notification notification = builder.build();
Notification notification = new Notification.Builder(context)
.setContent(rViews)//设置自定义界面
.setContentIntent(pi)
.setContentText("内容")
.setTicker("提示标题")
.setSmallIcon(R.drawable.ic_launcher)//显示的小图标
.setWhen(new Date().getTime())
.setLights(Color.GREEN, 2000, 1000)
.setVibrate(new long[]{0,1000,1000,1000,1000,1000,1000,1000,1000})
.setNumber(100)//显示在右边的数字
// .setExtras(bag)//带数据
.build();
// notification.ledARGB = Color.GREEN;//一般是绿色,黄色,红色
// notification.ledOffMS = 1000;
// notification.ledOnMS = 1000;
notification.flags = Notification.FLAG_SHOW_LIGHTS;//显示灯
//notification.flags = Notification.FLAG_AUTO_CANCEL;//点击这条消息后,自动取消
//通知管理器发送
manager.notify(1, notification);

}
}

光播的一些属性设置

标签:

原文地址:http://www.cnblogs.com/wangfeng520/p/5082955.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!