1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy of 6 * the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations under 14 * the License. 15 */ 16 17 package com.android.inputmethod.dictionarypack; 18 19 import android.content.BroadcastReceiver; 20 import android.content.Context; 21 import android.content.Intent; 22 23 public final class EventHandler extends BroadcastReceiver { 24 private static final String TAG = EventHandler.class.getName(); 25 26 /** 27 * Receives a intent broadcast. 28 * 29 * We receive every day a broadcast indicating that date changed. 30 * Then we wait a random amount of time before actually registering 31 * the download, to avoid concentrating too many accesses around 32 * midnight in more populated timezones. 33 * We receive all broadcasts here, so this can be either the DATE_CHANGED broadcast, the 34 * UPDATE_NOW private broadcast that we receive when the time-randomizing alarm triggers 35 * for regular update or from applications that want to test the dictionary pack, or a 36 * broadcast from DownloadManager telling that a download has finished. 37 * See inside of AndroidManifest.xml to see which events are caught. 38 * Also @see {@link BroadcastReceiver#onReceive(Context, Intent)} 39 * 40 * @param context the context of the application. 41 * @param intent the intent that was broadcast. 42 */ 43 @Override 44 public void onReceive(final Context context, final Intent intent) { 45 intent.setClass(context, DictionaryService.class); 46 context.startService(intent); 47 } 48 } 49