Android Open Source - WifiSaver Wakup Receiver






From Project

Back to project page WifiSaver.

License

The source code is released under:

MIT License

If you think the Android project WifiSaver 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 tma.wifisaver;
//from   ww  w .j a v a2 s.  c  o m
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.wifi.WifiManager;
import android.util.Log;

public class WakupReceiver extends BroadcastReceiver {

    //receiver for handling the screen turning on (user present)

    @Override
    public void onReceive(Context context, Intent intent) {
        WifiManager mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        AlarmManager mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);

        mWifiManager.setWifiEnabled(true);
        Intent mIntent = new Intent(context, WifiSwitchReceiver.class);

        PendingIntent mPendingIntent = PendingIntent.getBroadcast(context, Constants.REQUEST_CODE, mIntent, PendingIntent.FLAG_CANCEL_CURRENT);
        mAlarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + Constants.BROADCAST_TIME, mPendingIntent);

        Log.i("WifiSaver", "wifi on, broadcast 2 min");


    }

}




Java Source Code List

tma.wifisaver.BootReceiver.java
tma.wifisaver.Constants.java
tma.wifisaver.MainActivity.java
tma.wifisaver.NumberPickerFragment.java
tma.wifisaver.WakupReceiver.java
tma.wifisaver.WidgetProvider.java
tma.wifisaver.WifiSwitchReceiver.java
tma.wifisaver.WifiSwitchService.java