Android Open Source - BLEService Services Discovered Receiver

From Project

Back to project page BLEService.


The source code is released under:

Copyright (c) 2014, Ratio LLC. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: ...

If you think the Android project BLEService 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.ratio.deviceService.receivers;
//from  ww w  . ja v  a  2s.  c o  m
import java.util.ArrayList;
import java.util.List;

import com.ratio.deviceService.BTServiceProfile;
import com.ratio.deviceService.DeviceService;

import android.bluetooth.BluetoothGattService;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

 * broadcast receiver which returns the response from IDeviceCommand.discoverServices()
 * It de-parcels the device address and the BluetoothGattService list.
public abstract class ServicesDiscoveredReceiver extends BroadcastReceiver {

  public void onReceive(Context context, Intent intent) {
    String deviceAddress = intent.getStringExtra(DeviceService.EXTRA_DEVICE_ADDRESS);
       ArrayList<BTServiceProfile> serviceProfileList = (ArrayList<BTServiceProfile>) intent.getSerializableExtra(DeviceService.EXTRA_SERVICES);
       List<BluetoothGattService> serviceList = BTServiceProfile.getServiceList(serviceProfileList);
       onServicesDiscovered(deviceAddress, serviceList);
  public abstract void onServicesDiscovered(String deviceAdress, List<BluetoothGattService> serviceList);


Java Source Code List