1.小米手机无效,MIUI系统似乎改过android底层的一些东西


主要就是用到了AlarmManager,接着在AlarmReceiver实现notification 。  记得在manifest中添加AlarmReceiver即可

AlarmManager alarmManager = (AlarmManager) mContext.getSystemService(ALARM_SERVICE);Intent myIntent = new Intent(mContext, AlarmReceiver.class);myIntent.putExtra("msg", msg);myIntent.putExtra("id", count);// 第二个参数一定不一样 否则重复只会让最后一个起作用System.out.println("yzj id = " + count);PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, count++, myIntent, 0); alarmManager.set(AlarmManager.RTC, Calendar.getInstance().getTimeInMillis() + time, pendingIntent);

附上github地址:https://github.com/playscforever/TestLocalNotification.git (里面的NotificationService.java是不需要的)

更多相关文章

  1. Android(安卓)Service的两种启动方式
  2. someone's android note
  3. [置顶] Android-->Rxjava与Retrofit2的结合实战
  4. Android调用系统前置相机拍照
  5. Android(安卓)SharedPreferences的使用
  6. Android(安卓)opencv人脸识别
  7. Android(安卓)完美解决各个版本状态栏设置透明解决办法
  8. Android音效SoundPool问题:soundpool 1 not retry
  9. Android中利用HttpURLConnection发送Post请求并添加参数的写法

随机推荐

  1. android application级别的图片缓存
  2. 在android 只取vold相关的log信息
  3. android 获取系统和SD卡音乐
  4. Android图片解决方案
  5. Picasso picasso-强大的Android图片下载
  6. Android读取服务器图片
  7. android HTTP post方法时,如何使用cookies
  8. android 项目收获01
  9. Android(安卓)App第一次启动或者更新或第
  10. [Android]Generating Keys