Android Open Source - piRSS Boot Completed Handler






From Project

Back to project page piRSS.

License

The source code is released under:

GNU General Public License

If you think the Android project piRSS listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 * Copyright (C) 2011 Matthias Jordan <matthias.jordan@googlemail.com>
 *//from ww  w . j  a  v a 2  s.co m
 * This file is part of piRSS.
 *
 * piRSS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * piRSS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with piRSS.  If not, see <http://www.gnu.org/licenses/>.
 */
package de.codefu.android.rss;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import de.codefu.android.rss.db.ItemProvider;
import de.codefu.android.rss.updateservice.ServiceComm;



/**
 * Handles BOOT_COMPLETE message and makes sure that the auto poll mechanism is
 * started.
 * 
 * @author mj
 */
public class BootCompletedHandler extends BroadcastReceiver {

    /**
     * The tag for logging.
     */
    private static final String TAG = "BootCompletedHandler";


    @Override
    public void onReceive(Context context, Intent intent) {
        final String action = intent.getAction();
        if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
            deleteOrphanAuxRecords(context);
            handleAutopollPref(context);
        }

        if (Intent.ACTION_TIME_CHANGED.equals(action)) {
            handleAutopollPref(context);
        }
    }


    /**
     * Starts auto poll service if related preference option is set.
     * 
     * @param context
     *            the context
     */
    private void handleAutopollPref(Context context) {
        if (MainPreferences.getAutoPoll(context)) {
            ServiceComm.sendAutoPollIntent(context);
            Log.i(TAG, "Started auto poll service after boot");
        }
    }


    /**
     * Delete orphaned records in auxiliary table.
     * 
     * @param context
     *            the context
     */
    private void deleteOrphanAuxRecords(Context context) {
        context.getContentResolver().delete(ItemProvider.CONTENT_URI_AUX, null, null);
        Log.i(TAG, "Cleaned aux table after boot");
    }
}




Java Source Code List

de.codefu.android.rss.AboutActivity.java
de.codefu.android.rss.BootCompletedHandler.java
de.codefu.android.rss.CursorChangedReceiver.java
de.codefu.android.rss.MainPreferences.java
de.codefu.android.rss.UserNotification.java
de.codefu.android.rss.db.DB.java
de.codefu.android.rss.db.FeedProvider.java
de.codefu.android.rss.db.ItemHelper.java
de.codefu.android.rss.db.ItemProvider.java
de.codefu.android.rss.db.UriHelper.java
de.codefu.android.rss.feedlist.FeedListAdapter.java
de.codefu.android.rss.feedlist.FeedList.java
de.codefu.android.rss.feedprops.AddFeed.java
de.codefu.android.rss.feedprops.FeedProps.java
de.codefu.android.rss.item.ItemAct.java
de.codefu.android.rss.itemlist.ItemListAdapter.java
de.codefu.android.rss.itemlist.ItemList.java
de.codefu.android.rss.updateservice.AutoPollService.java
de.codefu.android.rss.updateservice.DateFormat3339.java
de.codefu.android.rss.updateservice.FeedHandlerClient.java
de.codefu.android.rss.updateservice.FeedHandler.java
de.codefu.android.rss.updateservice.InsertService.java
de.codefu.android.rss.updateservice.ServiceComm.java
de.codefu.android.rss.updateservice.UpdateService.java
de.codefu.android.rss.updateservice.UrlHttpRetriever.java
de.codefu.android.rss.updateservice.Utils.java
de.codefu.android.rss.updateservice.WakeLockHolder.java
de.codefu.android.rss.widgets.SimpleWidget.java