BootupBroadcastReceiver.java 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * ownCloud Android client application
  3. *
  4. * @author David A. Velasco
  5. * Copyright (C) 2012 Bartek Przybylski
  6. * Copyright (C) 2015 ownCloud Inc.
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2,
  10. * as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. */
  21. package com.owncloud.android.files;
  22. import com.owncloud.android.lib.common.utils.Log_OC;
  23. import com.owncloud.android.services.observer.FileObserverService;
  24. import android.content.BroadcastReceiver;
  25. import android.content.Context;
  26. import android.content.Intent;
  27. /**
  28. * App-registered receiver catching the broadcast intent reporting that the system was
  29. * just boot up.
  30. */
  31. public class BootupBroadcastReceiver extends BroadcastReceiver {
  32. private static String TAG = BootupBroadcastReceiver.class.getSimpleName();
  33. /**
  34. * Receives broadcast intent reporting that the system was just boot up.
  35. *
  36. * Starts {@link FileObserverService} to enable observation of favourite files.
  37. *
  38. * @param context The context where the receiver is running.
  39. * @param intent The intent received.
  40. */
  41. @Override
  42. public void onReceive(Context context, Intent intent) {
  43. if (!intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
  44. Log_OC.e(TAG, "Incorrect action sent " + intent.getAction());
  45. return;
  46. }
  47. Log_OC.d(TAG, "Starting file observer service...");
  48. Intent initObservers = FileObserverService.makeInitIntent(context);
  49. context.startService(initObservers);
  50. }
  51. }