18bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio/* 28bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio * Copyright (C) 2010 The Android Open Source Project 38bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio * 48bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio * Licensed under the Apache License, Version 2.0 (the "License"); 58bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio * you may not use this file except in compliance with the License. 68bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio * You may obtain a copy of the License at 78bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio * 88bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio * http://www.apache.org/licenses/LICENSE-2.0 98bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio * 108bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio * Unless required by applicable law or agreed to in writing, software 118bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio * distributed under the License is distributed on an "AS IS" BASIS, 128bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 138bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio * See the License for the specific language governing permissions and 148bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio * limitations under the License. 158bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio */ 168bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio 178bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Megliopackage com.android.providers.calendar; 188bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio 198bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglioimport android.app.Activity; 208bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglioimport android.content.BroadcastReceiver; 218bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglioimport android.content.Context; 228bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglioimport android.content.Intent; 238bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglioimport android.util.Log; 248bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio 258bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Megliopublic class CalendarProviderBroadcastReceiver extends BroadcastReceiver { 268bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio 278bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio @Override 288bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio public void onReceive(Context context, Intent intent) { 29420b7fb569773ae573fbe90c3a9c522d4c368863Erik if (!CalendarAlarmManager.ACTION_CHECK_NEXT_ALARM.equals(intent.getAction())) { 308bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio setResultCode(Activity.RESULT_CANCELED); 318bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio return; 328bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio } 338bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio final CalendarProvider2 provider = CalendarProvider2.getInstance(); 348bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio // Acquire a wake lock that will be released when the launched Service is doing its work 35420b7fb569773ae573fbe90c3a9c522d4c368863Erik provider.getOrCreateCalendarAlarmManager().acquireScheduleNextAlarmWakeLock(); 368bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio // Set the result code 378bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio setResultCode(Activity.RESULT_OK); 388bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio // Launch the Service 398bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio intent.setClass(context, CalendarProviderIntentService.class); 408bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio context.startService(intent); 418bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio } 428bb142159463f654ef07e20a341fcb527f0109f2Fabrice Di Meglio} 43