Loading AndroidManifest.xml +10 −1 Original line number Diff line number Diff line Loading @@ -107,7 +107,7 @@ </intent-filter> </receiver> <activity android:name="HandleSetAlarm" <activity android:name="HandleApiCalls" android:theme="@android:style/Theme.NoDisplay" android:excludeFromRecents="true" android:permission="com.android.alarm.permission.SET_ALARM"> Loading @@ -115,8 +115,17 @@ <action android:name="android.intent.action.SET_ALARM" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.SET_TIMER" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity-alias android:name="HandleSetAlarm" android:targetActivity=".HandleApiCalls" android:exported="true"> </activity-alias> <!-- This service receives the same intent as AlarmReceiver but it does not respond to the same broadcast. The AlarmReceiver will receive the alert broadcast and will start this service with the same Loading src/com/android/deskclock/HandleSetAlarm.java→src/com/android/deskclock/HandleApiCalls.java +29 −6 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.deskclock; import static android.provider.AlarmClock.ACTION_SET_ALARM; import static android.provider.AlarmClock.ACTION_SET_TIMER; import static android.provider.AlarmClock.EXTRA_HOUR; import static android.provider.AlarmClock.EXTRA_MESSAGE; import static android.provider.AlarmClock.EXTRA_MINUTES; Loading @@ -24,6 +25,7 @@ import static android.provider.AlarmClock.EXTRA_SKIP_UI; import android.app.Activity; import android.content.ContentResolver; import android.content.ContentValues; import android.content.Intent; import android.database.Cursor; import android.net.Uri; Loading @@ -33,16 +35,33 @@ import com.android.deskclock.provider.Alarm; import java.util.Calendar; public class HandleSetAlarm extends Activity { public class HandleApiCalls extends Activity { @Override protected void onCreate(Bundle icicle) { try { super.onCreate(icicle); Intent intent = getIntent(); if (intent == null || !ACTION_SET_ALARM.equals(intent.getAction())) { if (intent != null) { if (ACTION_SET_ALARM.equals(intent.getAction())) { handleSetAlarm(intent); } else if (ACTION_SET_TIMER.equals(intent.getAction())) { handleSetTimer(intent); } } } finally { finish(); return; } else if (!intent.hasExtra(EXTRA_HOUR)) { } } /*** * Processes the SET_ALARM intent * @param intent */ private void handleSetAlarm(Intent intent) { // Intent has no time , open the alarm creation UI if (!intent.hasExtra(EXTRA_HOUR)) { Intent createAlarm = new Intent(this, DeskClock.class); createAlarm.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); createAlarm.putExtra(Alarms.ALARM_CREATE_NEW, true); Loading Loading @@ -103,6 +122,10 @@ public class HandleSetAlarm extends Activity { finish(); } private void handleSetTimer(Intent intent) { } private boolean handleCursorResult(Cursor c, boolean enable, boolean skipUi) { if (c != null && c.moveToFirst()) { Alarm alarm = new Alarm(c); Loading Loading
AndroidManifest.xml +10 −1 Original line number Diff line number Diff line Loading @@ -107,7 +107,7 @@ </intent-filter> </receiver> <activity android:name="HandleSetAlarm" <activity android:name="HandleApiCalls" android:theme="@android:style/Theme.NoDisplay" android:excludeFromRecents="true" android:permission="com.android.alarm.permission.SET_ALARM"> Loading @@ -115,8 +115,17 @@ <action android:name="android.intent.action.SET_ALARM" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.SET_TIMER" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity-alias android:name="HandleSetAlarm" android:targetActivity=".HandleApiCalls" android:exported="true"> </activity-alias> <!-- This service receives the same intent as AlarmReceiver but it does not respond to the same broadcast. The AlarmReceiver will receive the alert broadcast and will start this service with the same Loading
src/com/android/deskclock/HandleSetAlarm.java→src/com/android/deskclock/HandleApiCalls.java +29 −6 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.deskclock; import static android.provider.AlarmClock.ACTION_SET_ALARM; import static android.provider.AlarmClock.ACTION_SET_TIMER; import static android.provider.AlarmClock.EXTRA_HOUR; import static android.provider.AlarmClock.EXTRA_MESSAGE; import static android.provider.AlarmClock.EXTRA_MINUTES; Loading @@ -24,6 +25,7 @@ import static android.provider.AlarmClock.EXTRA_SKIP_UI; import android.app.Activity; import android.content.ContentResolver; import android.content.ContentValues; import android.content.Intent; import android.database.Cursor; import android.net.Uri; Loading @@ -33,16 +35,33 @@ import com.android.deskclock.provider.Alarm; import java.util.Calendar; public class HandleSetAlarm extends Activity { public class HandleApiCalls extends Activity { @Override protected void onCreate(Bundle icicle) { try { super.onCreate(icicle); Intent intent = getIntent(); if (intent == null || !ACTION_SET_ALARM.equals(intent.getAction())) { if (intent != null) { if (ACTION_SET_ALARM.equals(intent.getAction())) { handleSetAlarm(intent); } else if (ACTION_SET_TIMER.equals(intent.getAction())) { handleSetTimer(intent); } } } finally { finish(); return; } else if (!intent.hasExtra(EXTRA_HOUR)) { } } /*** * Processes the SET_ALARM intent * @param intent */ private void handleSetAlarm(Intent intent) { // Intent has no time , open the alarm creation UI if (!intent.hasExtra(EXTRA_HOUR)) { Intent createAlarm = new Intent(this, DeskClock.class); createAlarm.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); createAlarm.putExtra(Alarms.ALARM_CREATE_NEW, true); Loading Loading @@ -103,6 +122,10 @@ public class HandleSetAlarm extends Activity { finish(); } private void handleSetTimer(Intent intent) { } private boolean handleCursorResult(Cursor c, boolean enable, boolean skipUi) { if (c != null && c.moveToFirst()) { Alarm alarm = new Alarm(c); Loading