mobile/android/base/sync/receivers/SyncAccountDeletedReceiver.java

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mobile/android/base/sync/receivers/SyncAccountDeletedReceiver.java	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,33 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +package org.mozilla.gecko.sync.receivers;
     1.9 +
    1.10 +import org.mozilla.gecko.background.common.log.Logger;
    1.11 +
    1.12 +import android.content.BroadcastReceiver;
    1.13 +import android.content.Context;
    1.14 +import android.content.Intent;
    1.15 +
    1.16 +public class SyncAccountDeletedReceiver extends BroadcastReceiver {
    1.17 +  public static final String LOG_TAG = "SyncAccountDeletedReceiver";
    1.18 +
    1.19 +  /**
    1.20 +   * This receiver can be killed as soon as it returns, but we have things to do
    1.21 +   * that can't be done on the main thread (network activity). Therefore we
    1.22 +   * start a service to do our clean up work for us, with Android doing the
    1.23 +   * heavy lifting for the service's lifecycle.
    1.24 +   * <p>
    1.25 +   * See <a href="http://developer.android.com/reference/android/content/BroadcastReceiver.html#ReceiverLifecycle">the Android documentation</a>
    1.26 +   * for details.
    1.27 +   */
    1.28 +  @Override
    1.29 +  public void onReceive(final Context context, Intent broadcastIntent) {
    1.30 +    Logger.debug(LOG_TAG, "Sync Account Deleted broadcast received.");
    1.31 +
    1.32 +    Intent serviceIntent = new Intent(context, SyncAccountDeletedService.class);
    1.33 +    serviceIntent.putExtras(broadcastIntent);
    1.34 +    context.startService(serviceIntent);
    1.35 +  }
    1.36 +}

mercurial