I have a very subtle question that might look grotesque, to more expert eyes than mine.
I'm implementing 2 distinct alarms, that survive reboot/shutdown and show a notification when fired.
One is a repeating daily reminder, and the other one is a monthly reminder which is reset by the app each time the user completes a given task.
Just to remind him/her to do it again when a month is passed.
Now, everything is working just fine.
So what's the problem?
Nothing, but I have the BootReceiver, AlarmReceiver and AlarmService doubled
Only the Notification builder is in common.
My question is then: Can I unify those elements and not have them splitted for any alarm?
Because if not, if in the future I'll need to schedule a weekly alarm, I'd have to make another boot receiver, alarm receiver and alarm service.
Which doesn't seem too smart, to me (say I add a weekly and a yearly tasks: I'd have to add 2 more of all receivers and services!! Which seems crazy, to me).
But maybe I'm wrong and things are to be like this?
In a previous app I wrote (before recognizing that it didn't pass reboots), it worked with the alarms sharing all the classes.
Thank you, guys, for your time.
If you need to see my code, just ask for it. But it's a bit long...
This is my Manifest file, just to show what my doubt is about:
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.scheduler2"
android:versionCode="1"
android:versionName="1.14.02.11 b"
>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18"
/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:theme="@style/Theme.Sample"
>
<!-- The Main Activity -->
<activity
android:name="com.example.android.scheduler2.ACT_Base"
android:label="@string/app_name"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- The Preference Activity -->
<activity android:name="com.example.android.scheduler2.ACT_Prefs" />
<!-- 2 Alarms = 2 Alarm Boot receivers -->
<!-- The One Shot Alarm Boot Receiver -->
<receiver
android:name="com.example.android.scheduler2.RCV_Boot_One"
android:enabled="false"
>
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<!-- The Repeating Alarm Boot Receiver -->
<receiver
android:name="com.example.android.scheduler2.RCV_Boot_Rep"
android:enabled="false"
>
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<!-- 2 Alarms = 2 Alarm receivers -->
<!-- The One Shot Alarm Receiver -->
<receiver android:name="com.example.android.scheduler2.RCV_Alarm_One" />
<!-- The Repeating Alarm Receiver -->
<receiver android:name="com.example.android.scheduler2.RCV_Alarm_Rep" />
<!-- 2 Alarms = 2 Alarm services -->
<!-- The One Shot Alarm Service -->
<service android:name="com.example.android.scheduler2.SVC_Alarm_One" />
<!-- The Repeating Alarm Service -->
<service android:name="com.example.android.scheduler2.SVC_Alarm_Rep" />
</application>
</manifest>