Example usage for android.app Service sendBroadcast

List of usage examples for android.app Service sendBroadcast

Introduction

In this page you can find the example usage for android.app Service sendBroadcast.

Prototype

@Override
    public void sendBroadcast(Intent intent) 

Source Link

Usage

From source file:uk.ac.horizon.ubihelper.service.channel.BluetoothDiscoveryChannel.java

/**
 * @param handler//from   w  w w .  j  a  v a  2 s  . co m
 * @param name
 */
public BluetoothDiscoveryChannel(Service service, Handler handler, String name) {
    super(handler, name);
    bluetooth = BluetoothAdapter.getDefaultAdapter();
    this.service = service;
    if (bluetooth == null)
        Log.w(TAG, "No BluetoothAdapter");
    if (!bluetooth.isEnabled()) {
        Intent i = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
        service.sendBroadcast(i);
    }
    IntentFilter filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
    filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
    filter.addAction(BluetoothDevice.ACTION_FOUND);
    filter.addAction(BluetoothDevice.ACTION_NAME_CHANGED);
    this.service.registerReceiver(receiver, filter);
}