Android Open Source - blue-tool-box Bluetooth L E Device Details Activity






From Project

Back to project page blue-tool-box.

License

The source code is released under:

Apache License

If you think the Android project blue-tool-box 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.eperu.bluemessenger;
/*from ww w. j av  a 2  s. c  o m*/
import android.app.Activity;
import android.bluetooth.BluetoothDevice;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

public class BluetoothLEDeviceDetailsActivity extends Activity {

  protected static final String TAG = "RangingActivity";

  /**
   * Valeur du header du dtail BlueTooth.
   */
  private TextView deviceNameValue, deviceAdressValue, deviceBluetoothClassValue, deviceBondStateLabelValue, deviceBondDetailsValue;

  private Button boundBtn;

  private LinearLayout linearLayout;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.bluetooth_device_details);
    this.linearLayout = (LinearLayout) this.findViewById(R.id.deviceDetailHeader);

    this.deviceNameValue = (TextView) this.findViewById(R.id.deviceNameValue);
    this.deviceAdressValue = (TextView) this.findViewById(R.id.deviceAdressValue);
    this.deviceBluetoothClassValue = (TextView) this.findViewById(R.id.deviceBluetoothClassValue);
    this.deviceBondStateLabelValue = (TextView) this.findViewById(R.id.deviceBondStateLabelValue);
    this.deviceBondDetailsValue = (TextView) this.findViewById(R.id.deviceBondDetailsValue);

    this.boundBtn = (Button) this.findViewById(R.id.boundBtn);
    this.boundBtn.setClickable(true);

    final BluetoothDevice bd = (BluetoothDevice) this.getIntent().getExtras().get("device");
    this.deviceNameValue.setText(bd.getName() + " iBeacon");

    this.deviceAdressValue.setText(bd.getAddress());
    this.deviceBluetoothClassValue.setText("" + bd.getBluetoothClass().getDeviceClass());
    String state = "Non Connect, cliquez sur le bouton";
    if (BluetoothDevice.BOND_BONDING == bd.getBondState()) {
      state = "En cours de connexion...";
    } else if (BluetoothDevice.BOND_BONDED == bd.getBondState()) {

    } else {
      this.boundBtn.setVisibility(View.VISIBLE);
    }
    this.deviceBondStateLabelValue.setText(state);

    this.boundBtn.setOnClickListener(new OnClickListener() {

      @Override
      public void onClick(View v) {
        System.out.println("Click");
        BluetoothManager.getInstance(BluetoothLEDeviceDetailsActivity.this).connect(bd.getAddress());
      }
    });
  }

  /*
   * (non-Javadoc)
   * 
   * @see android.app.Activity#onDestroy()
   */
  @Override
  protected void onDestroy() {
    super.onDestroy();
  }

}




Java Source Code List

com.eperu.bluemessenger.BluetoothDeviceDetailsActivity.java
com.eperu.bluemessenger.BluetoothLEDeviceDetailsActivity.java
com.eperu.bluemessenger.BluetoothManager.java
com.eperu.bluemessenger.MainActivity.java