为了账号安全,请及时绑定邮箱和手机立即绑定

警报管理器无法使用大秒针

警报管理器无法使用大秒针

当年话下 2021-09-03 17:09:08
我已经通过警报管理器制作了简单的警报,问题是当插入很多秒时它没有及时工作,我在这里声明这是代码 mo = ((Integer.parseInt(mons.getText().toString())) * (30 * 24 * 60 * 60));         we = ((Integer.parseInt(weeks.getText().toString())) * (7 * 24 * 60 * 60));         da = ((Integer.parseInt(days.getText().toString())) * (24 * 60 * 60));         ho = ((Integer.parseInt(hours.getText().toString())) * (60 * 60));         mi = ((Integer.parseInt(mins.getText().toString())) * (60));         int all = mo+we+da+ho+mi;       Intent i = new Intent(Messages.this, Alarm.class);       PendingIntent pd = PendingIntent.getBroadcast(getApplicationContext(), 5484, i, 0);       AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);       am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (all*1000), pd);这是接收器@Overridepublic void onReceive(Context context, Intent intent) {    Toast.makeText(context,"ALarm....",Toast.LENGTH_LONG).show();    showNotification( context);}private void showNotification(Context context) {    NotificationCompat.Builder mBuilder =            new NotificationCompat.Builder(context,"M_CH_ID")                .setSmallIcon(android.R.drawable.ic_dialog_alert)                .setContentTitle("فكرنى")                .setContentText("I think you need to do something")                .setAutoCancel(true);    mBuilder.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE);          NotificationManagerCompat mNotificationManager =    NotificationManagerCompat.from(context);    mNotificationManager.notify(1, mBuilder.build());}
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 104 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信