Example usage for android.content ReceiverCallNotAllowedException printStackTrace

List of usage examples for android.content ReceiverCallNotAllowedException printStackTrace

Introduction

In this page you can find the example usage for android.content ReceiverCallNotAllowedException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.hmatalonga.greenhub.managers.sampling.DataEstimator.java

public void getCurrentStatus(final Context context) {
    IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);

    try {/* ww  w  .j  av  a  2 s  .  com*/
        Intent batteryStatus = context.registerReceiver(null, ifilter);

        if (batteryStatus != null) {
            level = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
            scale = batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
            mHealth = batteryStatus.getIntExtra(BatteryManager.EXTRA_HEALTH, 0);
            plugged = batteryStatus.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0);
            present = batteryStatus.getExtras().getBoolean(BatteryManager.EXTRA_PRESENT);
            status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, 0);
            technology = batteryStatus.getExtras().getString(BatteryManager.EXTRA_TECHNOLOGY);
            temperature = (float) (batteryStatus.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, 0) / 10);
            voltage = (float) (batteryStatus.getIntExtra(BatteryManager.EXTRA_VOLTAGE, 0) / 1000);
        }
    } catch (ReceiverCallNotAllowedException e) {
        LOGE(TAG, "ReceiverCallNotAllowedException from Notification Receiver?");
        e.printStackTrace();
    }
}