zoukankan      html  css  js  c++  java
  • java课程之团队开发冲刺阶段1.9

      一.总结昨天进度

    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);
        }
  • 相关阅读:
    Mybatis整理
    Spring获取json和表单
    Mqtt(paho)重连机制
    Redis无法获取资源(Could not get a resource from the pool)
    SSM+Maven+Redis框架学习
    第一章 Zookeeper理论基础
    RocketMQ和Kafka对比
    Kafka工作原理与过程
    Kafka介绍
    JVM调优
  • 原文地址:https://www.cnblogs.com/heiyang/p/10809758.html
Copyright © 2011-2022 走看看