java课程之团队开发冲刺阶段1.9
2024-08-29 23:00:42
一.总结昨天进度
1.学习了简单的消息推送方法,并且能够使用进行每日定时推送
二.遇到的困难
1.在每日推送的过程中,程序必须被正常关闭,如果程序是被切到后天然后直接结束进程的话,每日推送的线程服务也会一切被kill,除非程序下次被打开,否则无法播报
三.今天的任务
1.对之前的功能进行整合,合并到一个程序当中。
当日总结:
1.总体来说查了不少资料,这个问题还是没有解决,调整完毕推送设置
public int onStartCommand(final Intent intent, int flags, int startId) { long period = 24*60*60*1000; //一天一个周期
int delay=intent.getIntExtra("delayTime",0);
if (null == timer ) {
timer = new Timer();
}
timer.schedule(new TimerTask() { @Override
public void run() {
// TODO Auto-generated method stub
NotificationManager mn= (NotificationManager) PushService.this.getSystemService(NOTIFICATION_SERVICE);
Notification.Builder builder = new Notification.Builder(PushService.this);
Intent notificationIntent = new Intent(PushService.this,MainActivity.class);//点击跳转位置
PendingIntent contentIntent = PendingIntent.getActivity(PushService.this,0,notificationIntent,0);
builder.setContentIntent(contentIntent);
builder.setSmallIcon(R.mipmap.ic_launcher);
builder.setTicker(intent.getStringExtra("tickerText")); //测试通知栏标题
builder.setContentText(intent.getStringExtra("contentText")); //下拉通知啦内容
builder.setContentTitle(intent.getStringExtra("contentTitle"));//下拉通知栏标题
builder.setAutoCancel(true);
builder.setDefaults(Notification.DEFAULT_ALL);
Notification notification = builder.build();
mn.notify((int)System.currentTimeMillis(),notification);
}
},delay, period); return super.onStartCommand(intent, flags, startId);
}
最新文章
- shell parameter expansitions
- 十.oc内存管理
- oracle,sqlserver同一个表两个字段和成一个列查询 (详询请加qq:2085920154)
- Mac 问题
- git 高级命令
- 高大上技术之sql解析
- Elasticsearch是一个分布式可扩展的实时搜索和分析引擎,elasticsearch安装配置及中文分词
- js 复制网页内容,兼容各浏览器
- ZOJ 2015 10月份 月赛 3911 Prime Query
- DB2 SQL RR/RS/CS/UR四个级别《转载》
- Colorful Lecture Note(手工栈)
- 脚本+批处理打造IIS监控器
- 阿里巴巴2018届应届生在线编程测验-研发工程师C/C++
- Linux show funny time[ liunx 有趣的东西展示]
- java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or.....
- Android为TV端助力 自定义activity
- Linux /var/log下的各种日志文件详解
- hadoop学习笔记叁--简单应用
- Java中 输入字符串的时候next()和nextLine()有什么区别
- 第四百一十二节,python接口,抽象方法抽象类