Android Open Source - Disposable-Apps Utils






From Project

Back to project page Disposable-Apps.

License

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;
/*ww  w .  j  a  v  a2s.co  m*/
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.SystemClock;


public abstract class Utils {
    public static void setUninstallTimer(final Context context, final int aid, final long milliseconds, final Uri packageUri) {
        final Intent intent = new Intent(context, UninstallReceiver.class);
        intent.putExtra("packageUri", packageUri);

        PendingIntent uninstallIntent = PendingIntent.getBroadcast(context, aid, intent, 0);

        if(uninstallIntent != null) {
            AlarmManager am = (AlarmManager) context.getSystemService(context.ALARM_SERVICE);
            am.cancel(uninstallIntent);
            am.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + milliseconds, uninstallIntent);
        }
    }

    public static void removeUninstallTimer(Context context, final Uri packageUri){
        final Intent intent = new Intent(context, UninstallReceiver.class);
        intent.putExtra("packageUri", packageUri);

        PendingIntent uninstallIntent = PendingIntent.getBroadcast(context, 0, intent, 0);

        if(uninstallIntent != null) {
            AlarmManager am = (AlarmManager) context.getSystemService(context.ALARM_SERVICE);
            am.cancel(uninstallIntent);
        }
    }
}




Java Source Code List

com.pennapps.disposableapps.AlarmAdapter.java
com.pennapps.disposableapps.Alarm.java
com.pennapps.disposableapps.AppInstalledActivity.java
com.pennapps.disposableapps.Bluetooth.java
com.pennapps.disposableapps.BootReceiver.java
com.pennapps.disposableapps.Constants.java
com.pennapps.disposableapps.Database.java
com.pennapps.disposableapps.EditAlarm.java
com.pennapps.disposableapps.Main.java
com.pennapps.disposableapps.PackageReceiver.java
com.pennapps.disposableapps.PackageUninstalledReceiver.java
com.pennapps.disposableapps.UninstallReceiver.java
com.pennapps.disposableapps.Utils.java