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

"Dolphins can smile", the biggest lie in the aquarium

During the National Day holiday, the aquarium is ...

Why can the 3K glasses in The Three-Body Problem see cosmic microwave radiation?

Gou Lijun Hello everyone, I am Gou Lijun from the...

Nokia brand, worth $55.2 billion in 2008, now discontinued

[[121650]] According to media reports, Microsoft ...

Luban e-commerce advertising National Day & Mid-Autumn Festival sales guide!

This article shares with you the National Day and...

Will the ill-fated Tizen make a comeback in low-end phones?

At the beginning of last year, Samsung launched t...

How to plan a marketing campaign that reaches 1 million people

When I first learned about the event, I actually ...

iOS upgrades stagnate, app crash rates slowly decrease

According to the weekly report released by Testin...

Jawbone up3 bracelet experience: playing is bigger

For most consumers, cost-effectiveness is the pri...

How to achieve high conversion rate in event poster copywriting?

How can event posters and poster copy achieve hig...

A complete guide to new media hit articles!

If you want your corporate WeChat public account ...

90% of “node marketing” is good idea, bad marketing

This article is reproduced from the public accoun...