de.unikassel.android.sdcframework.devices
Class SystemBroadcastReceivingDevice

Package class diagram package SystemBroadcastReceivingDevice
java.lang.Object
  extended by de.unikassel.android.sdcframework.devices.AbstractSensorDevice
      extended by de.unikassel.android.sdcframework.devices.SystemBroadcastReceivingDevice
All Implemented Interfaces:
SensorDevice, VisitableDevice
Direct Known Subclasses:
BluetoothDevice, WifiDevice

public abstract class SystemBroadcastReceivingDevice
extends AbstractSensorDevice

Abstract base class for sensor device which have to react on system state changes signaled by broadcasts.

In general that are devices like Wifi and Bluetooth, which can become disabled globally in the system while the device state change is broadcasted to the system.
Extending classes have to define the related Intent and to implement the handler for device state changes.

See Also:
WifiDevice, BluetoothDevice

Field Summary
protected  BroadcastReceiver receiver
          The broadcast receiver for device state changes
 
Constructor Summary
private SystemBroadcastReceivingDevice(SensorDeviceIdentifier deviceId)
          Constructor
  SystemBroadcastReceivingDevice(SensorDeviceIdentifier deviceId, Context applicationContext)
          Constructor
 
Method Summary
protected abstract  IntentFilter getIntentFilter()
          Getter for intent filter used by the broadcast receiver
protected  BroadcastReceiver getReceiver()
          Getter for the broadcast receiver
protected  void onConfigurationChanged()
          Callback to signal configuration of device has changed
 void onDestroy(Context context)
          Is called when the owner destroys this device
protected abstract  void onDeviceStateChange(Context context, Intent intent)
          Handler to react on broadcast intents for device changes
private  void registerReceiver(Context context)
          Does register the broadcast receiver
private  void setReceiver(BroadcastReceiver receiver)
          Setter for the receiver
private  void unregisterReceiver(Context context)
          Does unregister the broadcast receiver
 
Methods inherited from class de.unikassel.android.sdcframework.devices.AbstractSensorDevice
accept, doHandleDeviceDisabledBySystem, doHandleDeviceEnabledBySystem, doSignalDeviceNotEnabledInSystem, enableDeviceScanning, getConfiguration, getDeviceIdentifier, getScanner, isAirplaneModeOn, isDeviceScanningEnabled, onCreate, setDeviceIdentifier, setScanner, updateConfiguration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.unikassel.android.sdcframework.devices.facade.SensorDevice
isDeviceInSystemEnabled
 

Field Detail

receiver

protected BroadcastReceiver receiver
The broadcast receiver for device state changes

Constructor Detail

SystemBroadcastReceivingDevice

private SystemBroadcastReceivingDevice(SensorDeviceIdentifier deviceId)
Constructor

Parameters:
deviceId - the device identifier

SystemBroadcastReceivingDevice

public SystemBroadcastReceivingDevice(SensorDeviceIdentifier deviceId,
                                      Context applicationContext)
                               throws InvalidParameterException
Constructor

Parameters:
deviceId - the device identifier
applicationContext - the application context
Throws:
InvalidParameterException - is thrown in case of invalid parameters
Method Detail

setReceiver

private final void setReceiver(BroadcastReceiver receiver)
Setter for the receiver

Parameters:
receiver - the receiver to set

getReceiver

protected final BroadcastReceiver getReceiver()
Getter for the broadcast receiver

Returns:
the broadcast receiver

registerReceiver

private void registerReceiver(Context context)
Does register the broadcast receiver

Parameters:
context - the application context

unregisterReceiver

private void unregisterReceiver(Context context)
Does unregister the broadcast receiver

Parameters:
context - the application context

onDestroy

public final void onDestroy(Context context)
Description copied from interface: SensorDevice
Is called when the owner destroys this device

Specified by:
onDestroy in interface SensorDevice
Overrides:
onDestroy in class AbstractSensorDevice
Parameters:
context - the application context

onConfigurationChanged

protected void onConfigurationChanged()
Description copied from class: AbstractSensorDevice
Callback to signal configuration of device has changed

Specified by:
onConfigurationChanged in class AbstractSensorDevice

onDeviceStateChange

protected abstract void onDeviceStateChange(Context context,
                                            Intent intent)
Handler to react on broadcast intents for device changes

Parameters:
context - the context
intent - the intent

getIntentFilter

protected abstract IntentFilter getIntentFilter()
Getter for intent filter used by the broadcast receiver

Returns:
the intent filter used by the broadcast receiver