Android Open Source - WhatsApp-AutoClean Auto Clean Receiver






From Project

Back to project page WhatsApp-AutoClean.

License

The source code is released under:

Apache License

If you think the Android project WhatsApp-AutoClean 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 opensecurity.whatsappautoclean;
/*w w  w  . j av a 2s  .c  om*/
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import android.os.PowerManager;


public class AutoCleanReceiver extends BroadcastReceiver {
    final public static String ONE_TIME = "onetime";
    @Override
    public void onReceive(Context context, Intent intent) {
        PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "OPSEC");
        //Acquire the lock
        wl.acquire();
        context.startService(new Intent(context, AutoCleanService.class));
        //Release the lock
        wl.release();


    }
    public void SetAlarm(Context context,int seconds)
    {
        AlarmManager am=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
        Intent intent = new Intent(context, AutoCleanReceiver.class);
        intent.putExtra(ONE_TIME, Boolean.FALSE);
        PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, 0);
        am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 1000 * seconds , pi);
    }

    public void CancelAlarm(Context context)
    {
        Intent intent = new Intent(context, AutoCleanReceiver.class);
        PendingIntent sender = PendingIntent.getBroadcast(context, 0, intent, 0);
        AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
        alarmManager.cancel(sender);
    }



}




Java Source Code List

opensecurity.whatsappautoclean.ApplicationTest.java
opensecurity.whatsappautoclean.AutoCleanReceiver.java
opensecurity.whatsappautoclean.AutoCleanService.java
opensecurity.whatsappautoclean.AutoCleaner.java
opensecurity.whatsappautoclean.BuildConfig.java
opensecurity.whatsappautoclean.BuildConfig.java