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

我已经通过警报管理器制作了简单的警报,问题是当插入很多秒时它没有及时工作,我在这里声明


这是代码


 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);

这是接收器


@Override

public 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());

}


当年话下
浏览 105回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java