Bluetooth 4.0 BLE Development

Bluetooth 4.0 BLE Development

Source code introduction: Integrate the current mainstream Bluetooth demo

Source code effect:

Source code snippet:

  1. final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
  2. mBluetoothAdapter = bluetoothManager.getAdapter();
  3.    
  4. // Checks if Bluetooth is supported on the device.  
  5. if (mBluetoothAdapter == null ) {
  6. Toast.makeText( this , R.string.error_bluetooth_not_supported,
  7. Toast.LENGTH_SHORT).show();
  8. finish();
  9. return ;
  10. }
  11. // Turn on Bluetooth  
  12. mBluetoothAdapter.enable();
  13.    
  14. mBLE = new BluetoothLeClass( this );
  15. if (!mBLE.initialize()) {
  16. Log.e(TAG, "Unable to initialize Bluetooth" );
  17. finish();
  18. }
  19. // Callback when the BLE terminal's Service is discovered  
  20. mBLE.setOnServiceDiscoverListener(mOnServiceDiscover);
  21. // Receive the event of BLE terminal data interaction  
  22. mBLE.setOnDataAvailableListener(mOnDataAvailable);

Download address: http://download..com/data/2096560

<<:  Behind the rumors of Google entering China: the market structure has been determined or it may not adapt to the local environment

>>:  Photo browsing artifact source code sharing

Recommend

5 ways to increase the weight of Tik Tok!

So the question is, how to improve the weight of ...

Awesome copywriting, every sentence is a golden sentence

A copywriting that can touch people's hearts ...

App Delivery Growth: Marketing API

Marketing API (hereinafter referred to as MAPI) i...

Experience the YunOS version of MX4. Alibaba makes Flyme even better

On October 21, Alibaba and Meizu jointly held a p...

Countless spider webs fell from the sky, covering California, USA

The net of justice is vast and wide. October 5 wa...

5 health care misunderstandings that deceived parents, you will regret it now

Our parents gave us life and everything good. Whe...

Zhihu product analysis!

Zhihu was founded in 2011 and has been in operati...

How does APP choose marketing and promotion channels?

Q: How to choose marketing promotion channels ? A...

Milos training video

Milos training video resources introduction: Cour...

Use two pictures to tell you why your app freezes?

[[192710]] What's the material? You can get t...

Google and Fiat Chrysler team up to launch Android-based car system

According to Fortune, Google and Fiat Chrysler Au...