Android Open Source - EZ-Wifi-Notification Connectivity Broadcast Receiver






From Project

Back to project page EZ-Wifi-Notification.

License

The source code is released under:

GNU General Public License

If you think the Android project EZ-Wifi-Notification 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 et.nWifiManager;
/* w w w.  ja v  a2s  .  com*/
// ConnectivityBroadcastReceiver.java - Global reciever for all intent-filters
// Reciever for handling: 
//     android.net.conn.CONNECTIVITY_CHANGE, 
//     android.intent.action.AIRPLANE_MODE
//     android.intent.action.BOOT_COMPLETED
// then fires up WifiService with Intent

import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

/** Receiver for CONNECTIVITY_CHANGE, AIRPLANE_MODE, BOOT_COMPLETED
 * that fires up WifiService on start 
 * Everything runs inside a try/catch block to prevent non catched exceptions.
 *   
 * @author ET
 */
public class ConnectivityBroadcastReceiver extends BroadcastReceiver {

  private static final String TAG = "ConnectivityBroadcastReceiver";
  
  /**
   * onReceive must be very quick and not block, so it just fires up AnalyzeIntentService
   */
  @Override
  public void onReceive(Context context, Intent intent) {
    try {
      Log.v(TAG, "onReceived called");
      // Create Intent to AnalyzeIntentService
      final Intent intentService = new Intent(context, AnalyzeService.class);
      // Set action to recieved intent action.
      intentService.setAction(intent.getAction());
      // Pass Intent as Extra to AnalyzeIntentService
      if (AnalyzeService.AnalyzeExtras) intentService.putExtras(intent);        
      try {
        Log.v(TAG, "trying startService()");
        // Start service (AnalyzeIntentService)
        ComponentName component = context.startService(intentService);
        if (component != null) {
          // the service is being started or is already running,
          // the ComponentName of the actual service that was started
          // is returned;
          Log.d(TAG, "the service is being started or is already running");
        }
      } catch (SecurityException ex) {
        Log.e(TAG, ex.getMessage());
      }
    } catch (Exception ex) {      
      Log.e(TAG, ex.getMessage());
    }
  }
  
}




Java Source Code List

et.nWifiManager.AnalyzeService.java
et.nWifiManager.ConnectivityBroadcastReceiver.java
et.nWifiManager.Constants.java
et.nWifiManager.Hardware.java
et.nWifiManager.LauncerActivity.java
et.nWifiManager.MyApplication.java
et.nWifiManager.PreferencesActivity.java
et.nWifiManager.Analyzers.AnalyzerInterface.java
et.nWifiManager.Analyzers.BrutalAnalyzer.java
et.nWifiManager.Analyzers.ContextWrapperIntentAnalyzerBase.java
et.nWifiManager.Analyzers.IntentAnalyzerInterface.java
et.nWifiManager.Analyzers.IntentAnalyzer.java
et.nWifiManager.Message.Message.java
et.nWifiManager.Message.Messages.java
et.nWifiManager.Notificators.NotificationSettings.java
et.nWifiManager.Notificators.Notificator.java
et.nWifiManager.Notificators.SystemNotificator.java
et.nWifiManager.conState.ConnectionStatusEnum.java