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.