mobile/android/base/background/healthreport/HealthReportBroadcastReceiver.java

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:18d1c37654e0
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 package org.mozilla.gecko.background.healthreport;
6
7 import org.mozilla.gecko.background.common.log.Logger;
8
9 import android.content.BroadcastReceiver;
10 import android.content.Context;
11 import android.content.Intent;
12
13 /**
14 * Watch for notifications to start Health Report background services.
15 *
16 * Some observations:
17 *
18 * From the Android documentation: "Also note that as of Android 3.0 the user
19 * needs to have started the application at least once before your application
20 * can receive android.intent.action.BOOT_COMPLETED events."
21 *
22 * We really do want to launch on BOOT_COMPLETED, since it's possible for a user
23 * to run Firefox, shut down the phone, then power it on again on the same day.
24 * We want to submit a health report in this case, even though they haven't
25 * launched Firefox since boot.
26 */
27 public class HealthReportBroadcastReceiver extends BroadcastReceiver {
28 public static final String LOG_TAG = HealthReportBroadcastReceiver.class.getSimpleName();
29
30 /**
31 * Forward the intent to an IntentService to do background processing.
32 */
33 @Override
34 public void onReceive(Context context, Intent intent) {
35 Logger.debug(LOG_TAG, "Received intent - forwarding to BroadcastService.");
36 Intent service = new Intent(context, HealthReportBroadcastService.class);
37 service.putExtras(intent);
38 service.setAction(intent.getAction());
39 context.startService(service);
40 }
41 }

mercurial