Android Open Source - ShortcutsOfPower_Android N P Receiver






From Project

Back to project page ShortcutsOfPower_Android.

License

The source code is released under:

GNU General Public License

If you think the Android project ShortcutsOfPower_Android 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.networkprofiles.utils;
/*from  ww  w  . j  ava 2  s  .  co m*/
import android.appwidget.AppWidgetManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;

import com.networkprofiles.widget.NPWidgetService;

public class NPReceiver extends BroadcastReceiver {
  
  /** The strings that the BroadcastReceiver listens for **/
  public static final String ACTION_NP_WIDGET_MOBILE = "com.networkprofiles.ACTION_NP_WIDGET_MOBILE";
  public static final String ACTION_NP_WIDGET_CELL = "com.networkprofiles.ACTION_NP_WIDGET_CELL";
  public static final String ACTION_NP_WIDGET_GPS = "com.networkprofiles.ACTION_NP_WIDGET_GPS";
  public static final String ACTION_NP_WIDGET_DISPLAY = "com.networkprofiles.ACTION_NP_WIDGET_DISPLAY";
  public static final String ACTION_NP_WIDGET_SOUND = "com.networkprofiles.ACTION_NP_WIDGET_SOUND";
  SharedPreferences prefs;
  
  public void onReceive(Context context, Intent intent) {
    prefs = PreferenceManager.getDefaultSharedPreferences(context);
    
    Log.i("NPReceiver", "polu4en bradcast");
    String intentAction = intent.getAction();
    if(intentAction.equals(ACTION_NP_WIDGET_MOBILE)) {
      int[] ids = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
      Intent i = new Intent(context, NPWidgetService.class);
      i.putExtra("mobile", true);
      i.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids);
      context.startService(i);
    }
    if(intentAction.equals(ACTION_NP_WIDGET_CELL)) {
      int[] ids = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
      Intent i = new Intent(context, NPWidgetService.class);
      i.putExtra("cell", true);
      i.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids);
      context.startService(i);
    }
    if(intentAction.equals(ACTION_NP_WIDGET_GPS)) {
      int[] ids = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
      Intent i = new Intent(context, NPWidgetService.class);
      i.putExtra("gps", true);
      i.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids);
      context.startService(i);
    }
    if(intentAction.equals(ACTION_NP_WIDGET_DISPLAY)) {
      int[] ids = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
      Intent i = new Intent(context, NPWidgetService.class);
      i.putExtra("display", true);
      i.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids);
      context.startService(i);
    }
    if(intentAction.equals(ACTION_NP_WIDGET_SOUND)) {
      int[] ids = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
      Intent i = new Intent(context, NPWidgetService.class);
      i.putExtra("sound", true);
      i.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids);
      context.startService(i);
    }
  }
}




Java Source Code List

com.networkprofiles.MainNP.java
com.networkprofiles.SOPEula.java
com.networkprofiles.utils.ConstantsNP.java
com.networkprofiles.utils.MyNetControll.java
com.networkprofiles.utils.NPReceiver.java
com.networkprofiles.widget.NPWidgetCell.java
com.networkprofiles.widget.NPWidgetDisplay.java
com.networkprofiles.widget.NPWidgetGps.java
com.networkprofiles.widget.NPWidgetMobileData.java
com.networkprofiles.widget.NPWidgetService.java
com.networkprofiles.widget.NPWidgetSound.java