问题描述
我需要制作一个一个应用程序,为一周设置一个日历,
基本上,用户将在一周中每天的每天输入活动的开始时间和完成时间.
他只做一次.
在设置之后,应用程序(我将使用AlarmManager)将在设定的时间和完成时启动他的活动(连续播放视频)和设置小时:
一周中的每一天;
永远,
没有人为互动(当然,手机/平板电脑必须打开并插入电力).
我的担忧是以下内容:
将能够在早上实际唤醒设备以启动活动(播放视频)而没有来自用户的任何交互?
使用
的聪明建议WindowManager wm = Context.getSystemService(Context.WINDOW_SERVICE); Window window = getWindow(); window.addFlags(wm.LayoutParams.FLAG_DISMISS_KEYGUARD);
给我在日食中的大量错误:
推荐答案
是的,我可以尝试类似于它的东西,但不是完全......我尝试每天在9.00am每天调用设备,以下载我使用这段代码的内容
PowerManager pm = (PowerManager) context .getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wl = pm.newWakeLock( PowerManager.PARTIAL_WAKE_LOCK, ""); wl.acquire(); wl.release();
这是我的实现: 用于设置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:
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();
其他推荐答案
是警报是gd选项.如果设备被锁定,请使用keyguard dismiss ..
Window win = getWindow(); win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
在INVKING警报时并启动您想要在警报时的视频/音频活动或屏幕调用
还在设备上重启您需要重置警报
其他推荐答案
是的,如果使用ELAPSED_REALTIME_WAKEUP或RTC_WAKEUP作为警报类型.
问题描述
I need to make an App that set up a calendar for the week,
basically the user will input the start hour and finish hour of the activity for the every day of the week.
He will do only once.
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:
Every day of the week;
forever,
without human interaction (of course the phone/tablet must be switched on and plugged to electricity).
My concern is the following:
Will the alarmmanger be able to actually wake up the device in the morning to start the activity (play the video) without any interaction from the user?
The clever suggestion of using
WindowManager wm = Context.getSystemService(Context.WINDOW_SERVICE); Window window = getWindow(); window.addFlags(wm.LayoutParams.FLAG_DISMISS_KEYGUARD);
Gives me a lot of errors in Eclipse:
推荐答案
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();
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:
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();
其他推荐答案
yes alarm is gd option. use keyguard dismiss if the device is locked ..
Window win = getWindow(); win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
at the time of invking alarm & starting you video/audio activity or screen which you wants to be at the time of alarm get invoked
also on device reboot you need to reset the alarms
其他推荐答案
Yes, it will, if you use ELAPSED_REALTIME_WAKEUP or RTC_WAKEUP as the alarm type.