Example usage for android.content Intent ACTION_BATTERY_CHANGED

List of usage examples for android.content Intent ACTION_BATTERY_CHANGED

Introduction

In this page you can find the example usage for android.content Intent ACTION_BATTERY_CHANGED.

Prototype

String ACTION_BATTERY_CHANGED

To view the source code for android.content Intent ACTION_BATTERY_CHANGED.

Click Source Link

Document

Broadcast Action: This is a sticky broadcast containing the charging state, level, and other information about the battery.

Usage

From source file:com.google.code.twisty.Twisty.java

private void appendBatteryState(StringBuffer sb) {
    IntentFilter battFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
    Intent intent = registerReceiver(null, battFilter);

    int rawlevel = intent.getIntExtra("level", -1);
    int scale = intent.getIntExtra("scale", -1);
    int status = intent.getIntExtra("status", -1);
    int health = intent.getIntExtra("health", -1);
    int level = -1; // percentage, or -1 for unknown
    if (rawlevel >= 0 && scale > 0) {
        level = (rawlevel * 100) / scale;
    }/* www .  ja  v a  2s.c  o m*/
    sb.append("The device");
    if (BatteryManager.BATTERY_HEALTH_OVERHEAT == health) {
        sb.append("'s battery feels very hot!");
    } else {
        switch (status) {
        case BatteryManager.BATTERY_STATUS_UNKNOWN:
            // old emulator; maybe also when plugged in with no battery
            sb.append(" has no battery.");
            break;
        case BatteryManager.BATTERY_STATUS_CHARGING:
            sb.append("'s battery");
            if (level <= 33)
                sb.append(" is charging, and really ought to " + "remain that way for the time being.");
            else if (level <= 84)
                sb.append(" charges merrily.");
            else
                sb.append(" will soon be fully charged.");
            break;
        case BatteryManager.BATTERY_STATUS_DISCHARGING:
        case BatteryManager.BATTERY_STATUS_NOT_CHARGING:
            if (level == 0)
                sb.append(" needs charging right away.");
            else if (level > 0 && level <= 33)
                sb.append(" is about ready to be recharged.");
            else
                sb.append("'s battery discharges merrily.");
            break;
        case BatteryManager.BATTERY_STATUS_FULL:
            sb.append(" is fully charged up and ready to go on " + "an adventure of some sort.");
            break;
        default:
            sb.append("'s battery is indescribable!");
            break;
        }
    }
    sb.append(" ");
}

From source file:com.brewcrewfoo.performance.fragments.BatteryInfo.java

@Override
public void onResume() {
    super.onResume();
    try {/*from  w w  w  .j  av  a 2  s . c om*/
        getActivity().registerReceiver(batteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.tomi.ginatask.MainActivity.java

private void showDeviceInfoDialog() {
    TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    IntentFilter intentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
    Intent batteryStatus = this.registerReceiver(null, intentFilter);

    int level = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
    int scale = batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1);

    float batteryPct = (level / (float) scale) * 100;

    int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
    boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING
            || status == BatteryManager.BATTERY_STATUS_FULL;

    builder.setTitle("Device info")
            .setMessage("IMEI: " + telephonyManager.getDeviceId() + "\n\nBattery level: " + batteryPct + "% "
                    + (isCharging ? "(charging)" : "(not charging)"))
            .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                }/*from  w  ww . j a  v a2s. com*/
            }).show();
}

From source file:org.pixmob.freemobile.netstat.MonitorService.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override// w ww.j  a va  2  s  .  c  om
public void onCreate() {
    super.onCreate();

    pm = (PowerManager) getSystemService(POWER_SERVICE);
    tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
    cm = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);

    prefs = getSharedPreferences(SP_NAME, MODE_PRIVATE);
    prefs.registerOnSharedPreferenceChangeListener(this);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        final int largeIconWidth = getResources()
                .getDimensionPixelSize(android.R.dimen.notification_large_icon_width);
        final int largeIconHeight = getResources()
                .getDimensionPixelSize(android.R.dimen.notification_large_icon_height);
        if ((largeIconWidth > 0) && (largeIconHeight > 0)) {
            Bitmap freeLargeIconTmp = BitmapFactory.decodeResource(getResources(),
                    R.drawable.ic_stat_notify_service_free_large);
            if ((freeLargeIconTmp != null) && (freeLargeIconTmp.getWidth() > 0)
                    && (freeLargeIconTmp.getHeight() > 0)) {
                freeLargeIcon = Bitmap.createScaledBitmap(freeLargeIconTmp, largeIconWidth, largeIconHeight,
                        true);
            }

            Bitmap freeFemtoLargeIconTmp = BitmapFactory.decodeResource(getResources(),
                    R.drawable.ic_stat_notify_service_free_femto_large);
            if ((freeFemtoLargeIconTmp != null) && (freeFemtoLargeIconTmp.getHeight() > 0)
                    && (freeFemtoLargeIconTmp.getWidth() > 0)) {
                freeFemtoLargeIcon = Bitmap.createScaledBitmap(freeFemtoLargeIconTmp, largeIconWidth,
                        largeIconHeight, true);
            }

            Bitmap orangeLargeIconTmp = BitmapFactory.decodeResource(getResources(),
                    R.drawable.ic_stat_notify_service_orange_large);
            if ((orangeLargeIconTmp != null) && (orangeLargeIconTmp.getHeight() > 0)
                    && (orangeLargeIconTmp.getWidth() > 0)) {
                orangeLargeIcon = Bitmap.createScaledBitmap(orangeLargeIconTmp, largeIconWidth, largeIconHeight,
                        true);
            }
        }
    }

    // Initialize and start a worker thread for inserting rows into the
    // application database.
    final Context c = getApplicationContext();
    pendingInsert = new ArrayBlockingQueue<>(8);
    new PendingInsertWorker(c, pendingInsert).start();

    // This intent is fired when the application notification is clicked.
    openUIPendingIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_NOTIFICATION),
            PendingIntent.FLAG_CANCEL_CURRENT);

    // This intent is only available as a Jelly Bean notification action in
    // order to open network operator settings.
    Intent networkSettingsIntent = IntentFactory.networkOperatorSettings(this);
    if (networkSettingsIntent != null) {
        networkOperatorSettingsPendingIntent = PendingIntent.getActivity(this, 0, networkSettingsIntent,
                PendingIntent.FLAG_CANCEL_CURRENT);
    }
    Intent wirelessSettingsIntent = IntentFactory.wirelessSettings(this);
    if (wirelessSettingsIntent != null) {
        wirelessSettingsPendingIntent = PendingIntent.getActivity(this, 0, wirelessSettingsIntent,
                PendingIntent.FLAG_CANCEL_CURRENT);
    }

    // Watch screen light: is the screen on?
    screenMonitor = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            updateEventDatabase();
        }
    };

    final IntentFilter screenIntentFilter = new IntentFilter();
    screenIntentFilter.addAction(Intent.ACTION_SCREEN_ON);
    screenIntentFilter.addAction(Intent.ACTION_SCREEN_OFF);
    registerReceiver(screenMonitor, screenIntentFilter);

    // Watch Wi-Fi connections.
    connectionMonitor = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (onConnectivityUpdated()) {
                updateEventDatabase();
            }
        }
    };

    final IntentFilter connectionIntentFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
    registerReceiver(connectionMonitor, connectionIntentFilter);

    // Watch mobile connections.
    phoneMonitor = new PhoneStateListener() {
        @Override
        public void onDataConnectionStateChanged(int state, int networkType) {
            updateService();
        }

        @Override
        public void onServiceStateChanged(ServiceState serviceState) {
            if (stopServiceIfSimOperatorIsNotFreeMobile())
                return;

            mobileNetworkConnected = (serviceState != null)
                    && (serviceState.getState() == ServiceState.STATE_IN_SERVICE);

            updateService();
        }

        @Override
        public void onCellInfoChanged(List<CellInfo> cellInfo) {
            updateService();
        }

        private void updateService() {
            if (tm != null) { // Fix NPE - found by Acralyzer
                mobileNetworkType = tm.getNetworkType(); //update the network type to have the latest
            }
            final int phoneStateUpdated = onPhoneStateUpdated();
            if (phoneStateUpdated >= 0)
                updateEventDatabase();

            updateNotification(true, phoneStateUpdated == 1);
        }
    };
    int events = PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
        events |= PhoneStateListener.LISTEN_CELL_INFO;

    tm.listen(phoneMonitor, events);

    // Watch battery level.
    batteryMonitor = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            updateEventDatabase();
        }
    };

    batteryIntentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
    registerReceiver(batteryMonitor, batteryIntentFilter);

    shutdownMonitor = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            onDeviceShutdown();
        }
    };
    final IntentFilter shutdownIntentFilter = new IntentFilter();
    shutdownIntentFilter.addAction(Intent.ACTION_SHUTDOWN);
    // HTC devices use a different Intent action:
    // http://stackoverflow.com/q/5076410/422906
    shutdownIntentFilter.addAction("android.intent.action.QUICKBOOT_POWEROFF");
    registerReceiver(shutdownMonitor, shutdownIntentFilter);

    if (prefs.getBoolean(SP_KEY_ENABLE_AUTO_RESTART_SERVICE, false) && Arrays
            .asList(ANDROID_VERSIONS_ALLOWED_TO_AUTO_RESTART_SERVICE).contains(Build.VERSION.RELEASE)) {
        // Kitkat and JellyBean auto-kill service workaround
        // http://stackoverflow.com/a/20735519/1527491
        ensureServiceStaysRunning();
    }
}

From source file:com.android.settings.Settings.java

@Override
public void onResume() {
    super.onResume();

    mDevelopmentPreferencesListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
        @Override/*from w  w  w.  j  av  a2 s. c  o  m*/
        public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
            invalidateHeaders();
        }
    };
    mDevelopmentPreferences.registerOnSharedPreferenceChangeListener(mDevelopmentPreferencesListener);
    // SPRD:ADD register receiver.
    ListAdapter listAdapter = getListAdapter();
    if (listAdapter instanceof HeaderAdapter) {
        // add for tab style
        ((HeaderAdapter) listAdapter).flushViewCache();
        // add for tab style
        ((HeaderAdapter) listAdapter).resume();
    }
    // SPRD:ADD update Header
    invalidateHeaders();

    registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));

    //revo lyq 2014 for advan settings
    if (is_advan_settings) {
        IntentFilter mIntentFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
        mIntentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
        registerReceiver(mReceiver, mIntentFilter);
    }

}

From source file:com.rareventure.gps2.GpsTrailerService.java

@Override
public void onCreate() {
    Log.d(TAG, "GPS Service Startup");

    //android.os.Debug.waitForDebugger(); //FODO 1 IXME DISABLE!

    Nammu.init(this);

    //reset all flags
    notificationFlags = 0;//from   w ww  . j a  v  a2s . c  om

    updateNotification(FLAG_GPS_ENABLED, true);

    GTG.addGTGEventListener(gtgEventListener);

    //read isCollectData first from shared prefs and if its false, quit immediately
    //we don't want to notify the user that we ran for any reason if this is false
    // (for example the db was corrupted)
    GTG.prefSet.loadAndroidPreferencesFromSharedPrefs(this);

    //co: we initially don't want to do anything if the user is unlicensed,
    // just find out how much piracy is a problem
    if (!GTG.prefs.isCollectData) //|| GTGEvent.ERROR_UNLICENSED.isOn)
    {
        turnOffNotification();
        stopSelf();
        return;
    }

    GTG.initRwtm.registerWritingThread();
    try {

        try {
            GTG.requireInitialSetup(this, true);

            GTG.requirePrefsLoaded(this);

            if (!GTG.requireNotInRestore()) {
                updateNotification(FLAG_IN_RESTORE, true);
                stopSelf();

                return;
            }

            Intent i = GTG.requireNotTrialWhenPremiumIsAvailable(this);

            if (i != null) {
                turnOffNotification();
                stopSelf();

                return;
            }

            if (!GTG.requireNotTrialExpired()) {
                updateNotification(FLAG_TRIAL_EXPIRED, true);
                stopSelf();

                return;
            }

            if (!GTG.requireSdcardPresent(this)) {
                updateNotification(FLAG_ERROR_SDCARD_NOT_MOUNTED, true);
                stopSelf();

                return;
            }

            if (!GTG.requireSystemInstalled(this)) {
                stopSelf();
                return;
            }

            if (GTG.requireDbReady() != GTG.REQUIRE_DB_READY_OK) {
                updateNotification(FLAG_ERROR_DB_PROBLEM, true);
                stopSelf();

                return;
            }

            GTG.requireEncrypt();
        } finally {
            GTG.initRwtm.unregisterWritingThread();
        }

        updateNotification(FLAG_COLLECT_ENABLED, true);

        //co because we don't want gps2data files in the root directory of sdcard. they take up too much space
        //                 SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        //                 File dataFile = new File(Environment.getExternalStorageDirectory(), "gps2data"+sdf.format(new Date())+".txt");
        File dataFile = null;
        gpsManager = new GpsTrailerManager(dataFile, this, TAG, this.getMainLooper());
        //         gpsManager = new GpsTrailerManager(null, this, TAG,
        //               this.getMainLooper());

        //note that there is no way to receive the current status of the battery
        //However, the battery receiver will get a notification as soon as its registered
        // to the current status of the battery
        batteryReceiver = new BroadcastReceiver() {

            @Override
            public void onReceive(Context context, Intent intent) {
                float batteryLeft = ((float) intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1))
                        / intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);

                /* ttt_installer:remove_line */Log.d(GTG.TAG,
                        "Received battery info, batteryLeft: " + batteryLeft);

                int status = intent.getIntExtra("status", BatteryManager.BATTERY_STATUS_UNKNOWN);

                if (batteryLeft < GTG.prefs.minBatteryPerc
                        && (status == BatteryManager.BATTERY_STATUS_DISCHARGING
                                || status == BatteryManager.BATTERY_STATUS_UNKNOWN)) {
                    updateNotification(FLAG_BATTERY_LOW, true);
                    GTG.alert(GTGEvent.ERROR_LOW_BATTERY);
                } else
                    updateNotification(FLAG_BATTERY_LOW, false);

                //we wait until now to finish startup 
                //because otherwise if the battery is low
                //and we are awoken for some other event, we would otherwise show our icon for
                //a brief period before we get the battery is low event
                updateNotification(FLAG_FINISHED_STARTUP, true);

                //just a hack, a reasonable place to check if the trial version has expired
                checkTrialExpired();
            }
        };

        IntentFilter batteryLevelFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
        registerReceiver(batteryReceiver, batteryLevelFilter);

        gpsManager.start();

    } catch (Exception e) {
        shutdownWithException(e);
        ACRA.getErrorReporter().handleException(e);
    }
}

From source file:org.huxizhijian.hhcomicviewer.ui.entry.GalleryActivity.java

@Override
protected void onResume() {
    super.onResume();
    batteryBroadcastReceiver = new BatteryBroadcastReceiver();
    ////from   w  w w .ja v a  2  s.c o m
    IntentFilter intentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
    registerReceiver(batteryBroadcastReceiver, intentFilter);
}

From source file:org.restcomm.app.qoslib.Services.Intents.IntentHandler.java

@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    Bundle intentExtras = intent.getExtras();

    if (owner == null)
        return;// w  ww.ja  v  a  2  s. c o m
    owner.getWebSocketManager().sendIntentToWebSocket(action, intentExtras);

    //capture the "battery changed" event
    if (action.equals(Intent.ACTION_BATTERY_CHANGED)) {
        int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
        int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, 100);
        DeviceInfoOld.battery = level * 100 / scale;
        int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
        boolean bCharging = plugged == BatteryManager.BATTERY_PLUGGED_AC
                || plugged == BatteryManager.BATTERY_PLUGGED_USB;
        owner.setBatteryCharging(bCharging);
        dataMonitorStats.setBattery(bCharging, DeviceInfoOld.battery);
    } else if (action.equals(Intent.ACTION_POWER_CONNECTED)) {
        owner.setBatteryCharging(true);
        dataMonitorStats.setBattery(true, null);
    } else if (action.equals(Intent.ACTION_POWER_DISCONNECTED)) {
        owner.setBatteryCharging(false);
        dataMonitorStats.setBattery(false, null);
    } else if (action.equals(Intent.ACTION_VIEW)) {
        //this is supposed to trigger the update event
        //owner.triggerUpdateEvent(false, false);
    } else if (action.equals(CommonIntentActionsOld.ACTION_START_UI)) {
        String packagename = intent.getStringExtra("packagename");
        String mypackagename = context.getPackageName();
        PreferenceManager.getDefaultSharedPreferences(context).edit()
                .putString(PreferenceKeys.Miscellaneous.YEILDED_SERVICE, packagename).commit();
        // If the UI started on a different MMC app UI, then we stop this service until this UI is launched
        if (!packagename.equals(mypackagename)) // This will exit the service when safe, and won't restart it because it will be yeilded
            owner.restartSelf();
    } else if (action.equals(UPDATE_ACTION)) {
        owner.getEventManager().triggerUpdateEvent(false, false);
    } else if (action.equals(COLDRESET_ACTION)) {
        //this is supposed to trigger the update event
        owner.getGpsManager().coldStart("triggered by user");
    } else if (action.equals(EMAIL_CSV)) {
        //this is supposed to trigger the update event
        owner.requestCsvEmail();
    } else if (action.equals(SPEED_TEST)) {
        //this is supposed to trigger a speed test
        int trigger = intent.getIntExtra(CommonIntentBundleKeysOld.EXTRA_SPEED_TRIGGER, 0);
        //owner.triggerSMSTest(trigger);
        owner.getEventManager().queueActiveTest(EventType.MAN_SPEEDTEST, trigger);
    } else if (action.equals(RUN_WEBSOCKET)) {
        //this is supposed to trigger a speed test
        boolean bStart = intent.getBooleanExtra(EXTRA_START_WEBSOCKET, true);
        owner.getWebSocketManager().runWebSocket(bStart);
        //owner.triggerSpeedTest(trigger);
    } else if (action.equals(ACTIVE_TEST)) {
        //this is supposed to trigger a speed test
        int evType = intent.getIntExtra(CommonIntentBundleKeysOld.EXTRA_TEST_TYPE, 0);
        EventType eventType = EventType.get(evType);
        int trigger = intent.getIntExtra(CommonIntentBundleKeysOld.EXTRA_SPEED_TRIGGER, 0);
        owner.getEventManager().queueActiveTest(eventType, trigger);
    } else if (action.equals(SMS_TEST)) {
        //this is supposed to trigger a speed test
        int trigger = intent.getIntExtra(CommonIntentBundleKeysOld.EXTRA_SPEED_TRIGGER, 0);
        //owner.triggerSMSTest(trigger);
        owner.getEventManager().queueActiveTest(EventType.SMS_TEST, trigger);
    } else if (action.contains(SMS_DELIVERED)) {
        //add delivery time to connection history

        int identifier = intent.getIntExtra("identifier", 0); //in case we need to search connection list to find which SMS
        long deliveryTime = 0;

        switch (getResultCode()) {
        case Activity.RESULT_OK:
            deliveryTime = System.currentTimeMillis();
            break;
        case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
            deliveryTime = -1;
            break;
        case SmsManager.RESULT_ERROR_NO_SERVICE:
            deliveryTime = -1;
            break;
        case SmsManager.RESULT_ERROR_NULL_PDU:
            deliveryTime = -1;
            break;
        case SmsManager.RESULT_ERROR_RADIO_OFF:
            deliveryTime = -1;
            break;
        }

        owner.getEventManager().handleSMSDeliverNotification(identifier, deliveryTime);
    } else if (action.equals(LATENCY_TEST)) {
        int trigger = intent.getIntExtra(CommonIntentBundleKeysOld.EXTRA_SPEED_TRIGGER, 0);
        owner.getEventManager().queueActiveTest(EventType.LATENCY_TEST, trigger);
        //owner.runLatencyTest(false);
    } else if (action.equals(ACTION_STOP_SPEEDTEST)) {
        owner.getEventManager().killSpeedTest();
    } else if (action.equals(ACTION_STOP_VIDEOTEST)) {
        int testType = intent.getIntExtra(CommonIntentBundleKeysOld.EXTRA_TEST_TYPE, 0);
        owner.getEventManager().killActiveTest(testType);
    } else if (action.equals(ROAMING_ON)) {
        dataMonitorStats.setRoaming(true);
    } else if (action.equals(ROAMING_OFF)) {
        dataMonitorStats.setRoaming(false);
    } else if (action.equals("android.intent.action.ANY_DATA_STATE")) {
        String apn = intentExtras.getString("apn");
        String state = intentExtras.getString("state");
        String apnType = intentExtras.getString("apnType");
        String extras = apnType + "" + state;
        if (state.equals("CONNECTED") && !apnType.equals("default"))
            extras = extras + "!";
        if (apnType != null && apnType.equals("default") && apn != null) {
            SharedPreferences securePref = MainService.getSecurePreferences(context);
            securePref.edit().putString(PreferenceKeys.Miscellaneous.KEY_APN, apn).commit();
        }

    } else if (action.equals("android.intent.action.DATA_CONNECTION_CONNECTED_TO_PROVISIONING_APN")) {
        String apn = intentExtras.getString("apn");
        String apnType = intentExtras.getString("apnType");
        String extras = apn + "," + apnType;
    } else if (action.equals("android.intent.action.ACTION_DATA_CONNECTION_FAILED")) {
        String phoneName = intentExtras.getString("phoneName");
        String reason = intentExtras.getString("reason");
        String extras = phoneName + "," + reason;
    } else if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
        if (owner.getUsageLimits().getDormantMode() > 0)
            return;
        // wifi state change may trigger the event queue to be sent
        //MMCLogger.logToFile(MMCLogger.Level.DEBUG, "MMCIntentHandlerOld", "NETWORK_STATE_CHANGED_ACTION", "");
        owner.wifiStateChange((NetworkInfo) intentExtras.getParcelable(WifiManager.EXTRA_NETWORK_INFO));
        owner.trackAccessPoints(0);
        dataMonitorStats.setWifi(PhoneState.isNetworkWifi(owner));
    } else if (action.equals(WIMAX_STATE_CHANGE)) {
        owner.trackAccessPoints(0);
    } else if (action.equals(BluetoothDevice.ACTION_ACL_CONNECTED)) {
        //         BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
        //         BluetoothClass bclass = device.getBluetoothClass();
        //         int major = bclass.getMajorDeviceClass();
        //         if (major == 1024)
        //            owner.setBTHeadsetState(1);
        //         owner.trackAccessPoints();
    } else if (action.equals(BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED)) {
        owner.trackAccessPoints(0);
    } else if (action.equals(BluetoothDevice.ACTION_ACL_DISCONNECTED)) {
        //         BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
        //         BluetoothClass bclass = device.getBluetoothClass();
        //         int major = bclass.getMajorDeviceClass();
        //         if (major == 1024)
        //            owner.setBTHeadsetState(0);
        //         owner.trackAccessPoints();
    } else if (action.equals(Intent.ACTION_HEADSET_PLUG)) {
        try {
            int state = intent.getIntExtra("state", -1);
            owner.setHeadsetState(state);
        } catch (Exception e) {
            LoggerUtil.logToFile(LoggerUtil.Level.ERROR, TAG, "onReceive",
                    "error receiving Intent.ACTION_HEADSET_PLUG: " + e);
        }
    } else if (action.equals(Intent.ACTION_HEADSET_PLUG)) {
        int state = intent.getIntExtra("state", -1);
        owner.setHeadsetState(state);
    } else if (action.equals(CommonIntentActionsOld.ACTION_START_VOICETEST)) {
        //this is supposed to trigger a speed test
        int trigger = intent.getIntExtra(CommonIntentBundleKeysOld.EXTRA_VQ_TRIGGER, 0);
        owner.getVQManager().runTest(trigger);
    } else if (action.equals(CommonIntentActionsOld.ACTION_TEST_VQ_DEVICE)) {
        owner.getVQManager().runTest(10);
    } else if (action.equals(CommonIntentActionsOld.ACTION_STOP_VOICETEST)) {
        owner.getVQManager().killTest();
    } else if (action.equals(RESTART_MMC_SERVICE)) {
        owner.restartNextIdle();

    } else if (action.equals(STOP_TRACKING_ACTION)) {
        owner.getEventManager().stopTracking();
    } else if (action.equals(Intent.ACTION_SCREEN_OFF)) {
        try {
            dataMonitorStats.setScreen(false);
            SignalEx mmcSignal = new SignalEx();
            owner.getPhoneStateListener().processNewMMCSignal(mmcSignal);
            if (owner.getTravelDetector() != null) {
                owner.getPhoneState().screenChanged(false);
                owner.getEventManager().screenChanged(false);
            }
        } catch (Exception e) {
            LoggerUtil.logToFile(LoggerUtil.Level.ERROR, TAG, "onReceive",
                    "received action SCREEN_OFF, calling MainService.processNewMMCSignal()", e);
        }
    } else if (action.equals(Intent.ACTION_SCREEN_ON)) {
        dataMonitorStats.setScreen(true);
        if (owner.getTravelDetector() != null) {
            owner.getPhoneState().screenChanged(true);
            owner.getEventManager().screenChanged(true);
        }
    } else if (action.equals(ACTION_ALARM_MINUTE)) {
        // CPU wakes very briefly only in order to spur cellid updates
        owner.getTravelDetector().triggerTravelCheck();
        QosAPI.checkHostApp(context);
    } else if (action.equals(ACTION_TRACKING_5MINUTE)) {
        owner.getTrackingManager().runTracking();
    } else if (action.equals(ACTION_TRACKING_1MINUTE)) {
        LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, TAG, "onReceive", "ACTION_TRACKING_1MINUTE");
        owner.getTrackingManager().runTrackingTests();
    } else if (action.equals(ACTION_ALARM_3HOUR)) {
        dataMonitorStats.prepareAllStatistics();
        owner.getEventManager().triggerUpdateEvent(true, false);
        //         Calendar cal = Calendar.getInstance(); 
        //          int hour = cal.get (Calendar.HOUR_OF_DAY); 
        //         //If 12pm to 3 am
        //          if(((hour >= 0 && hour <= 3) || hour == 24) && owner.isNetworkWifi()) {
        //            //See if transit info needs to be downloaded
        //             
        //             //Don't allow the app to shut down until the work is done, keep the CPU running
        //             MMCLogger.logToFile(MMCLogger.Level.DEBUG, TAG, "onReceive", "ACTION_ALARM_3HOUR, wakelock turned on and checking transit "
        //                   + "info uptodate at 24-hour: " + hour);
        //             wakeLock.acquire();
        //             
        //             downloadAreasIfOutOfDate();
        //          }
    }
    //      else if(action.equals(ACTION_TRANSIT_DL_DONE)) {
    //         //Allow CPU to move on
    //         if(wakeLock != null) {
    //            wakeLock.release(); 
    //            MMCLogger.logToFile(MMCLogger.Level.DEBUG, TAG, "onReceive", "received action ACTION_TRANSIT_DONE, wakelock turned off");
    //         }
    //      }
    //      else if(action.equals(ACTION_TRANSIT_DL_START)) {
    //         //Don't allow the app to shut down until the work is done, keep the CPU running
    //          MMCLogger.logToFile(MMCLogger.Level.DEBUG, TAG, "onReceive", "ACTION_TRANSIT_DL_START, wakelock turned on and downloading transit if was requested");
    //          wakeLock.acquire();
    //          
    //          downloadAreasIfOutOfDate();
    //      }
    else if (action.equals(ACTION_ALARM_SCANAPPS)) {
        int intervalDM = PreferenceManager.getDefaultSharedPreferences(owner)
                .getInt(PreferenceKeys.Miscellaneous.MANAGE_DATAMONITOR, 0);
        // run datamonitor if enabled
        if (intervalDM > 0) {
            dataMonitorStats.scanApps();
            dataMonitorStats.getRunningAppsString(false); // for debug
        }

        // Also using this timer for GCM heartbeats (its a 5 minute heartbeat to tell Google Cloud Messaging to check the socket more often for more reliable push messages)
        // 2 independent timers might wake up device twice as often, doubling the battery impact, so I'm forcing it to use one for both cases
        //         boolean useHeartbeat = PreferenceManager.getDefaultSharedPreferences(owner).getBoolean("KEY_GCM_HEARTBEAT", false);
        //         if (useHeartbeat) {
        //            GcmKeepAlive gcm = new GcmKeepAlive(owner);
        //            gcm.broadcastIntents();
        //         }
    } else if (action.equals(ACTION_ALARM_15MINUTE)) {

        int intervalDM = PreferenceManager.getDefaultSharedPreferences(owner)
                .getInt(PreferenceKeys.Miscellaneous.MANAGE_DATAMONITOR, 0);
        // run datamonitor if enabled
        if (intervalDM > 0) {
            boolean firstBucketDone = PreferenceManager.getDefaultSharedPreferences(owner)
                    .getBoolean(PreferenceKeys.Miscellaneous.FIRST_BUCKET, false);
            if (!firstBucketDone) { //if false, first bucket needs to be done
                dataMonitorStats.firstBucket();
                dataMonitorStats.monitor();
                PreferenceManager.getDefaultSharedPreferences(owner).edit()
                        .putBoolean(PreferenceKeys.Miscellaneous.FIRST_BUCKET, true).commit();
                LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, "MMCIntentHandlerOld", "onReceive",
                        "First bucket at: " + System.currentTimeMillis() / 1000);
            } else {
                dataMonitorStats.monitor();
                //MMCLogger.logToFile(MMCLogger.Level.DEBUG, "MMCIntentHandlerOld", "onReceive", "15 min bucket at: " + System.currentTimeMillis()/1000);
            }
        }
        // regardless, still make sure GPS is idle unless needed
        owner.getGpsManager().safeguardGps();
    } else if (action.equals(GPS_STATE_ON)) {
        dataMonitorStats.setGps(true);
    } else if (action.equals(GPS_STATE_OFF)) {
        dataMonitorStats.setGps(false);
    } else if (action.equals(PHONE_CALL_CONNECT)) {
        dataMonitorStats.setPhone(true);
    } else if (action.equals(PHONE_CALL_DISCONNECT)) {
        dataMonitorStats.setPhone(false);
    } else if (action.equals(HANDOFF)) {
        dataMonitorStats.handoff();
    } else if (action.equals(MANUAL_TRANSIT_START)) {
        long lat = intent.getIntExtra("latitude", 0);
        long lon = intent.getIntExtra("longitude", 0);
        Location location = new Location("");
        location.setLatitude(lat / 1000000.0);
        location.setLongitude(lon / 1000000.0);
        location.setAccuracy(-3);

        //         PreferenceManager.getDefaultSharedPreferences(owner).edit().putString(
        //                PreferenceKeys.Miscellaneous.SURVEY_COMMAND,).commit();
        PreferenceManager.getDefaultSharedPreferences(owner).edit()
                .putString("transitEvent", String.valueOf(lat) + "," + String.valueOf(lon)).commit();
        reportManager.manualTransitEvent = owner.getEventManager().triggerSingletonEvent(EventType.MAN_TRANSIT);
        reportManager.manualTransitEvent.setLocation(location, 0);
        owner.getTravelDetector().setTravelling(false);
    } else if (action.equals(MANUAL_TRANSIT_END)) {
        if (reportManager.manualTransitEvent == null)
            return;
        String accelData = intent.getStringExtra("accelerometer");
        int stationFrom = intent.getIntExtra("stationFrom", 0);
        int stationTo = intent.getIntExtra("stationTo", 0);
        int duration = intent.getIntExtra("duration", 0);
        int corrected = intent.getIntExtra("corrected", 0);
        if (corrected != 0) {
            Location location = reportManager.manualTransitEvent.getLocation();
            location.setAccuracy(-4);
        }

        reportManager.manualTransitEvent.setAppData(accelData); //TODO want this to really be in appdata?
        reportManager.manualTransitEvent.setLookupid1(stationFrom);
        reportManager.manualTransitEvent.setLookupid2(stationTo);
        reportManager.manualTransitEvent.setDuration(duration);
        owner.getEventManager().unstageAndUploadEvent(reportManager.manualTransitEvent, null);
        reportManager.manualTransitEvent = null;
    } else if (action.equals(MANUAL_TRANSIT_CANCEL)) {
        if (reportManager.manualTransitEvent != null) {
            owner.getEventManager().unstageEvent(reportManager.manualTransitEvent);
            ReportManager reportManager = ReportManager.getInstance(owner);
            reportManager.getDBProvider().delete(TablesEnum.LOCATIONS.getContentUri(),
                    "timestamp > ? And accuracy = 3",
                    new String[] { String.valueOf(reportManager.manualTransitEvent.getEventTimestamp()) });
            reportManager.manualTransitEvent = null;
        }
    } else if (action.equals(MANUAL_PLOTTING_START)) {
        int floor = intent.getIntExtra("floor", 0);
        //         int type = intent.getIntExtra("type", -1);  //1(indoor) or 2(outdoor)
        int topFloor = intent.getIntExtra("top", -1);
        int lat = intent.getIntExtra("latitude", -1);
        int lng = intent.getIntExtra("longitude", -1);
        long osm_id = intent.getLongExtra("osm_id", 0);
        String poly = intent.getStringExtra("poly");

        reportManager.manualPlottingEvent = owner.getEventManager()
                .triggerSingletonEvent(EventType.MAN_PLOTTING);
        reportManager.manualPlottingEvent.setEventIndex(floor);
        reportManager.manualPlottingEvent.setDuration(topFloor);
        reportManager.manualPlottingEvent.setBuildingID(osm_id);
        reportManager.manualPlottingEvent.setAppData(poly);
        Location location = new Location("");
        location.setLatitude(lat / 1000000.0);
        location.setLongitude(lng / 1000000.0);
        location.setAccuracy(-1);
        reportManager.updateEventField(reportManager.manualPlottingEvent.getLocalID(), "latitude",
                Double.toString(location.getLatitude()));
        reportManager.updateEventField(reportManager.manualPlottingEvent.getLocalID(), "longitude",
                Double.toString(location.getLongitude()));

        reportManager.manualPlottingEvent.setLocation(location, 0);
        presetEventId(reportManager.manualPlottingEvent); // reserve an EventID for this manual sampling event, to be used for Share links

        owner.getTravelDetector().setTravelling(false);
    } else if (action.equals(MANUAL_PLOTTING_END)) {
        LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, TAG, "onReceive", "MANUAL_PLOTTING_END");
        //         owner.getEventManager().unstageEvent(manulaPlottingEvent); //does not upload
        if (reportManager.manualPlottingEvent != null)
            owner.getEventManager().unstageAndUploadEvent(reportManager.manualPlottingEvent, null);
        //After the event was submitted, reset it so we don't restore an old event in ManualMapping
        reportManager.manualPlottingEvent = null;
    } else if (action.equals(MANUAL_PLOTTING_CANCEL)) {
        if (reportManager.manualPlottingEvent != null) {
            reportManager.getDBProvider().delete(TablesEnum.LOCATIONS.getContentUri(),
                    "timestamp > ? And accuracy < 0",
                    new String[] { String.valueOf(reportManager.manualPlottingEvent.getEventTimestamp()) });
            reportManager.manualPlottingEvent = null;

        }
    }
    //      else if(intent.getAction().equals(MMS_RECEIVED)) {
    //         LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, TAG, "onReceived MMS_RECEIVED", intentExtras.toString());
    //      }
    //      else if(intent.getAction().equals(MMS_SENT)) {
    //         LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, TAG, "onReceived MMS_SENT", intentExtras.toString());
    //      }
    //      else if(intent.getAction().equals(SMS_REJECTED)) {
    //         LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, TAG, "onReceived SMS_REJECTED", intentExtras.toString());
    //      }
    else if (intent.getAction().equals(SMS_RECEIVED)) {
        SmsMessage[] msgs = null;
        //         String msg_from;
        if (intentExtras == null)
            return;

        Object[] pdus = (Object[]) intentExtras.get("pdus");
        msgs = new SmsMessage[pdus.length];
        String[] msgBody = new String[msgs.length];
        for (int i = 0; i < msgs.length; i++) {
            msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
            //            msg_from = msgs[i].getOriginatingAddress();
            String msg = msgs[i].getMessageBody().trim();
            if (msg.length() > 10) {
                msg = msg.substring(1, msg.length() - 1);
                msg = "{" + msg + "}";
            }

            msgBody[i] = msg;

        }
        handleCommands(msgBody, true, 0);
    } else if (action.equals(VIEWING_SIGNAL)) {
        owner.setEnggQueryTime();
    } else if (intent.getAction().equals(SURVEY)) {
        if (intentExtras == null)
            return;

        int surveyid = intentExtras.getInt(SURVEY_EXTRA);
        postSurvey(surveyid);
    } else if (intent.getAction().equals(GCM_MESSAGE)) {
        if (intentExtras == null)
            return;
        try {
            String msg = intentExtras.getString(GCM_MESSAGE_EXTRA);
            long starttime = intentExtras.getLong("GCM_STARTTIME_EXTRA");
            EventResponse eventResponse = gson.fromJson(msg, EventResponse.class);
            eventResponse.init();
            eventResponse.setStartTime(starttime);
            eventResponse.handleEventResponse(owner, true);
        } catch (Exception e) {
            LoggerUtil.logToFile(LoggerUtil.Level.ERROR, TAG, "onReceived GCM_MESSAGE", "exception", e);
        }
    } else if (intent.getAction().equals(COMMAND)) {
        if (intentExtras == null)
            return;

        String commands = intentExtras.getString(COMMAND_EXTRA);
        if (commands == null)
            return;
        long starttime = intent.getLongExtra("STARTTIME_EXTRA", 0);
        String[] msgs = null;
        try {
            JSONArray cmds = new JSONArray(commands);
            msgs = new String[cmds.length()];
            for (int j = 0; j < cmds.length(); j++)
                msgs[j] = cmds.getJSONObject(j).toString();
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            //e.printStackTrace();
        }
        //commands = commands.replace("[", "");
        //commands = commands.replace("]", "");
        //String msgs[] = commands.split("/");
        handleCommands(msgs, false, starttime);
    }

    else if (intent.getAction().equals(TelephonyManager.ACTION_PHONE_STATE_CHANGED)) {
        int val = 0;
        val = intent.getIntExtra("android.telecom.extra.CALL_DISCONNECT_CAUSE", -1);
        String msg = intent.getStringExtra("android.telecom.extra.CALL_DISCONNECT_CAUSE");
        String msg2 = intent.getStringExtra("android.telecom.extra.CALL_DISCONNECT_MESSAGE");
        //MMCLogger.logToFile(MMCLogger.Level.ERROR, TAG, "String CALL_DISCONNECT_CAUSE", msg);
        //MMCLogger.logToFile(MMCLogger.Level.ERROR, TAG, "Int CALL_DISCONNECT_CAUSE", ""+val);
    } else if (intent.getAction().equals("android.intent.action.NEW_OUTGOING_CALL")) {
        String phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
        //if (phoneNumber != null)
        //    MMCLogger.logToFile(MMCLogger.Level.ERROR, TAG, "NEW_OUTGOING_CALL", phoneNumber);
    }

    else if (intent.getAction().equals("android.intent.action.PRECISE_CALL_STATE")) {
        int val = 0;
        //val = intent.getIntExtra("android.telecom.extra.CALL_DISCONNECT_CAUSE", -1);
        int state_ringing = intent.getIntExtra("ringing_state", -1);
        int state_foreground = intent.getIntExtra("foreground_state", -1);
        int state_background = intent.getIntExtra("background_state", -1);

        int disconnect_cause = intent.getIntExtra("disconnect_cause", -1);
        int precise_disconnect_cause = intent.getIntExtra("precise_disconnect_cause", -1);
        PreciseCallCodes precisecall = new PreciseCallCodes(state_ringing, state_foreground, state_background,
                disconnect_cause, precise_disconnect_cause);
        LoggerUtil.logToFile(LoggerUtil.Level.ERROR, TAG, "PRECISE_CALL_STATE", precisecall.toString());
        owner.getPhoneStateListener().onPreciseCallState(precisecall);
    } else if (intent.getAction().equals("android.intent.action.PRECISE_DATA_CONNECTION_STATE_CHANGED")) {
        int val = 0;
        //val = intent.getIntExtra("android.telecom.extra.CALL_DISCONNECT_CAUSE", -1);
        int state = intent.getIntExtra("state", -1);
        int networkType = intent.getIntExtra("networkType", -1);
        String reason = intent.getStringExtra("reason");
        String failCause = intent.getStringExtra("failCause");
        String apnType = intent.getStringExtra("apnType");
        String apn = intent.getStringExtra("apn");
        Object linkProperties = intent.getParcelableExtra("linkProperties");
        if (!apnType.equals("default"))
            return;
        //         if (failCause != null && failCause.length() > 0)
        //         {
        //            String msg = String.format("state:%d,netType:%d,apnType:%s,reason:%s\r\nfailCause:%s", state,networkType,apnType,reason,failCause);
        //            MMCLogger.logToFile(MMCLogger.Level.ERROR, TAG, "PRECISE_DATA_CONNECTION_STATE_CHANGED", msg);
        //            if (linkProperties != null)
        //            {
        //               msg = String.format("PRECISE_DATA_CONNECTION_STATE_CHANGED  linkProperties:%s", linkProperties.toString());
        //               MMCLogger.logToFile(MMCLogger.Level.ERROR, TAG, "PRECISE_DATA_CONNECTION_STATE_CHANGED", msg);
        //            }
        //         }
        //         else if (reason != null && reason.length() > 0)
        //         {
        //            String msg = String.format("state:%d,netType:%d,apnType:%s,reason:%s\r\nfailCause:%s", state,networkType,apnType,reason,failCause);
        //            MMCLogger.logToFile(MMCLogger.Level.ERROR, TAG, "PRECISE_DATA_CONNECTION_STATE_CHANGED", msg);
        //            if (linkProperties != null)
        //            {
        //               msg = String.format("PRECISE_DATA_CONNECTION_STATE_CHANGED  linkProperties:%s", linkProperties.toString());
        //               MMCLogger.logToFile(MMCLogger.Level.ERROR, TAG, "PRECISE_DATA_CONNECTION_STATE_CHANGED", msg);
        //            }
        //         }
    } else if (intent.getAction().equals("org.restcomm.android.CONNECT_FAILED")
            || intent.getAction().equals("org.restcomm.android.CALL_STATE")
            || intent.getAction().equals("org.restcomm.android.DISCONNECT_ERROR")) {
        owner.getPhoneStateListener().getRestCommManager().handleIntent(owner, intent);
    } else if (intent.getAction().equals(ACTION_RADIOLOG_DISCONNECT)) {
        String time = intent.getStringExtra(EXTRA_RADIOLOG_TIME);
        String cause = intent.getStringExtra(EXTRA_RADIOLOG_DISC_CAUSE);
        owner.getPhoneStateListener().onDisconnect(time, cause);
    } else if (intent.getAction().equals(ACTION_RADIOLOG_CONNECT)) {
        String time = intent.getStringExtra(EXTRA_RADIOLOG_TIME);
        String state = intent.getStringExtra(EXTRA_RADIOLOG_CONN_STATE);
        owner.getPhoneStateListener().onConnect(time, state);
    } else if (intent.getAction().equals(ACTION_RADIOLOG_NEIGHBORS)) {
        String time = intent.getStringExtra(EXTRA_RADIOLOG_TIME);
        String neighbors = intent.getStringExtra(EXTRA_RADIOLOG_NEIGHBORS);
        //owner.onConnect(time, state);
    } else if (intent.getAction().equals(ACTION_RADIOLOG_SERVICEMODE)) {
        String time = intent.getStringExtra(EXTRA_RADIOLOG_TIME);
        String jsonstr = intent.getStringExtra(EXTRA_RADIOLOG_SVC_JSON);
        JSONObject json = null;
        try {
            json = new JSONObject(jsonstr);
        } catch (Exception e) {
        }
        String values = intent.getStringExtra(EXTRA_RADIOLOG_SVC_TEXT);
        String name = intent.getStringExtra(EXTRA_RADIOLOG_SVC_NAME);
        owner.getPhoneStateListener().onServiceMode(time, json, values, name);
    } else if (intent.getAction().equals(ACTION_RADIOLOG_SERVICEMENU)) {
        String time = intent.getStringExtra(EXTRA_RADIOLOG_TIME);
        String values = intent.getStringExtra(EXTRA_RADIOLOG_SVC_TEXT);
        String name = intent.getStringExtra(EXTRA_RADIOLOG_SVC_NAME);
        owner.getPhoneStateListener().onServiceMenu(time, values, name);
    } else if (intent.getAction().equals(ACTION_MMCSYS_VERSION)) {
        Integer version = intent.getIntExtra(EXTRA_MMCSYS_VERSION, 0);
        owner.onSvcModeVersion(version);
    } else if (intent.getAction().equals(ACTION_RADIOLOG_ERROR)) {
        String error = intent.getStringExtra(EXTRA_RADIOLOG_ERROR);
        String details = intent.getStringExtra(EXTRA_RADIOLOG_ERROR_DETAIL);
        LoggerUtil.logToFile(LoggerUtil.Level.ERROR, "RilReader", error, details);
        //owner.onConnect(time, state);
    }

}

From source file:com.ubuntuone.android.files.service.UpDownService.java

private void registerChargingReceiver(BroadcastReceiver receiver) {
    IntentFilter filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
    getApplicationContext().registerReceiver(receiver, filter);
}

From source file:org.uguess.android.sysinfo.SiragonManager.java

@Override
public void onResume() {
    aborted = false;/*from  ww w.j  a v a2  s.com*/

    super.onResume();

    getActivity().registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));

    updateInfo();
}