簡體   English   中英

如何顯示未遂意圖中的預防活動進展

[英]How to show progress in prefrence activity pending intent

我想按一定的時間間隔自動執行任務。我按待定意圖調用了服務,如下所示

             alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
    mAlarmSender = PendingIntent.getService(Schedule.this, 0, new    Intent(Schedule.this,
                                        Schedule_service.class), 0);
                        new Thread(new Runnable() {
                            public void run() {
                                Schedule.this.finish();
                                alarmManager.setRepeating(
                                        AlarmManager.RTC_WAKEUP, SysTime,
                                        interval, mAlarmSender);
                                state = true;
                            }
                        }).start();

但是當服務運行時出現空白屏幕,當我按下后退按鈕時強制關閉。所以我在異步任務中嘗試了它,以顯示進度直到服務完成,但它也無濟於事。請提供任何解決方案或指導,謝謝。

Intent intent = new Intent(context, reminderService.class);
        PendingIntent pendingIntent = PendingIntent.getService(context, 1, intent, 0);
        AlarmManager alarmmanager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);

        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);

        alarmmanager.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 1000 * 60 * 60 * 24, pendingIntent);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM