机器人:机器人能AlarmManager唤醒设备来执行计划任务? [英] Android: can Android AlarmManager wake up the device to perform the scheduled task?

查看:163
本文介绍了机器人:机器人能AlarmManager唤醒设备来执行计划任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请我有以下的情况,并请我需要一个建议。

Please I have the following situation and please I need an advice.

我需要作出规定:设立一个日历的一周,

I need to make an App that set up a calendar for the week,

基本上,用户将输入的

  • 开始时间

&安培;

  • 在完成一小时

有一周中的每一天的活性。

of the activity for the every day of the week.

他会做的只有一次。

在此之后成立,该应用程序(我将使用 AlarmManager )将开始他的活动(连续播放视频)在设定的小时完成,并设定时间:

After that set up, the application (I will use AlarmManager) will start his activity (continuously play video) at the set hour and finish and the set hour:

一周的每一天;

永远

无需人工交互(当然手机/平板电脑必须在交换和插电)。

without human interaction (of course the phone/tablet must be switched on and plugged to electricity).

我关心的是以下内容:

将在ALARMMANAGER能够真正唤醒设备,早上启动活动(播放视频) 白化任何来自用户从这里到永恒互动? : - )

WILL THE ALARMMANAGER BE ABLE TO ACTUALLY WAKE UP THE DEVICE IN THE MORNING TO START THE ACTIVITY (play the video) WHITEOUT ANY INTERACTION FROM THE USER FROM HERE TO ETERNITY ? :-)

非常感谢你!

LISA ANNE

LISA ANNE

编辑编辑编辑编辑 通过巧妙的建议

EDIT EDIT EDIT EDIT the clever suggestion of using

    WindowManager wm = Context.getSystemService(Context.WINDOW_SERVICE);
    Window window = getWindow();  
    window.addFlags(wm.LayoutParams.FLAG_DISMISS_KEYGUARD);

给了我很多的错误在Eclipse:

Gives me a lot of errors in Eclipse:

推荐答案

是的u能我想类似,但不是exactly..i试图在每天上午9点至下载的内容调用设备我用这块code

Yes u can i tried something similar to that but not exactly..i tried invoking the device every day at 9.00AM to download the contents i used this piece of code

PowerManager pm = (PowerManager) context
            .getSystemService(Context.POWER_SERVICE);
    PowerManager.WakeLock wl = pm.newWakeLock(
            PowerManager.PARTIAL_WAKE_LOCK, "");
    wl.acquire();

    wl.release();

这是我的实现:   用于设置Alaram

This was my implementation: Used to set the Alaram

 AlarmManager am = (AlarmManager) context
            .getSystemService(Context.ALARM_SERVICE);
     Calendar calendar = Calendar.getInstance();
     calendar.setTimeInMillis(System.currentTimeMillis());
     calendar.add(Calendar.MINUTE, 10);
     calendar.add(Calendar.SECOND, 00);
     //alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
     am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), 1000*60*1, pi);

BroadcastReciever:

BroadcastReciever:

Register BroadcastReciever:
PowerManager pm = (PowerManager) context
            .getSystemService(Context.POWER_SERVICE);
    PowerManager.WakeLock wl = pm.newWakeLock(
            PowerManager.PARTIAL_WAKE_LOCK, "");
    wl.acquire();
    // Put here YOUR code.

    Intent startAutoSyncService = new Intent(context,
            AppoinmentService.class);
    context.startService(startAutoSyncService);

    wl.release();

这篇关于机器人:机器人能AlarmManager唤醒设备来执行计划任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆