Android Open Source - Disposable-Apps Boot Receiver

From Project

Back to project page Disposable-Apps.


The source code is released under:

GNU Lesser General Public License

If you think the Android project Disposable-Apps 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

package com.pennapps.disposableapps;
//from   w  ww  .  j a  v a 2  s .  com
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import java.util.ArrayList;

public class BootReceiver extends BroadcastReceiver {

    public void onReceive(Context context, Intent intent) {
        Log.d("DisposableApps", "Boot Completed");

        // Start the app install activity
        Database alarmDb = new Database(context);
        ArrayList<Alarm> alarms = alarmDb.selectAllAlarms();

        for (Alarm alarm : alarms) {
            long alarmDate = alarm.getTime();
            long currentDate = System.currentTimeMillis();

            long alarmSetDate = alarmDate - currentDate;

            // want to check for events that passed while shut off or otherwise
            if (alarmSetDate > 0) {
                Utils.setUninstallTimer(context, alarm.getAid(), alarmSetDate, alarm.getPackageUri());
            } else {
                Utils.setUninstallTimer(context, alarm.getAid(), 10000, alarm.getPackageUri());

Java Source Code List