Android Open Source - cloudwave Connectivity Change Receiver






From Project

Back to project page cloudwave.

License

The source code is released under:

Apache License

If you think the Android project cloudwave 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.luboganev.cloudwave.receivers;
//from  ww  w .ja  v  a2 s  .  c om
import com.commonsware.cwac.wakeful.WakefulIntentService;
import com.luboganev.cloudwave.LogUtils;
import com.luboganev.cloudwave.service.ChangeWallpaperService;
import com.luboganev.cloudwave.service.CommunicationUtils;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

/**
 * This broadcast receiver gets notified when network connectivity 
 * has changed. It is registered in the app's manifest but is not
 * enabled the whole time. It is being enabled when we want to get
 * some new sound wave image or other info from Soundcloud API, but 
 * there is currently no Internet connectivity. When the Internet 
 * connectivity is available again, it calls the execution of all 
 * the necessary work and disables itself again. 
 */
public class ConnectivityChangeReceiver extends BroadcastReceiver {
  @Override
  public void onReceive(Context context, Intent intent) {
    if(CommunicationUtils.hasInternetConnectivity(context)) {
      LogUtils.d(this, "OMG, there is internet! Better start working then.");
      // we have internet, have the change wallpaper service called
      Intent serviceIntent = new Intent(context, ChangeWallpaperService.class);
      WakefulIntentService.sendWakefulWork(context, serviceIntent);
      // disable this broadcastReceiver
      CommunicationUtils.setConnectivityChangeReceiverEnabled(context, false);
    }
  }
}




Java Source Code List

com.luboganev.cloudwave.CloudWaveWallpaper.java
com.luboganev.cloudwave.LogUtils.java
com.luboganev.cloudwave.data.LocalStorageManager.java
com.luboganev.cloudwave.data.LocalStorage.java
com.luboganev.cloudwave.data.Track.java
com.luboganev.cloudwave.receivers.AlarmReceiver.java
com.luboganev.cloudwave.receivers.ConnectivityChangeReceiver.java
com.luboganev.cloudwave.service.ChangeWallpaperService.java
com.luboganev.cloudwave.service.CommunicationUtils.java