Android: Concept for day-sensitive scheduled App-start (Alarm Clock)
-
Hoí there,
somehow I´m not able to find an explicit english forum for Android develoopment - which I find hard to believe to extend, I think I´m missing something...
How ever
In the scope of an individual alarm-clock app based on Qt , running on Android, I´m trying to figure out, what the approrpiate way is, to start an app at a certain time AND certain selectable days.
What does already work
I do have solved to start my app at a given time from what I found link text and in addition squeezing ChatGPT.public class RestartNotificationClient { private static AlarmManager alarmMgr; private static PendingIntent alarmIntent; //private static OverlayAppToLockScreen; public static void notify(Context context, int hour, int minute) { alarmMgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); //Intent intent = new Intent(); //intent.setComponent(new ComponentName("org.qtproject.example.androidnotifier", "AlarmNotification")); Intent intent = context.getPackageManager().getLaunchIntentForPackage("org.qtproject.example.androidnotifier"); //System.out.println(view); if(intent == null) System.out.println("Wrong wrong wrong wrong"); alarmIntent = PendingIntent.getActivity(context, 0, intent, Intent.FLAG_ACTIVITY_NEW_TASK); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.set(Calendar.HOUR_OF_DAY, hour); calendar.set(Calendar.MINUTE, minute); alarmMgr.setExact( AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), alarmIntent); } }
What I´m wondering
Since the app is an alarm-clock, it is also possible to choose the day - e.g. monday to friday out of the whole week.
How would I sensibly implement that?
Would it be like per day having a weekly scheduled alarm set - so up to 7 alarms / intents per alarm-instance?
Or is there a more clever way?