Giter Club home page Giter Club logo

dubluetooth's Introduction


有兴趣的可以关注【Python2048】 公众号
分享技术、灰色产业、职业规划、赚钱之道、逆向破解等趣事……


DuBluetooth

Descript

Please see -- If you have any other questions, please check here.   Android 蓝牙开发(整理大全)

Version

- V1.0.0 

	-- 根据别人修改的一个版本 --  给大家作为参考学习使用

- V0.0.9

	-- 代码测试使用

Code

Please see
* MainActivity
* SettingActivity
* SearchActivity
* ComminuteActivity

MainActivity ->  onActivityResult .
	 //返回消息处理
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (resultCode == RESULT_OK) {
            Uri uri = data.getData();
            try {
                bluetooth.comminute(openLockBytes, 1);
                Thread.sleep(100);
                String path = BluetoothUtils.getPath(uri, MainActivity.this);
                bluetooth.sendKey((BluetoothUtils.createKey(path)).getBytes());
                Thread.sleep(100);
                lockBt.setImageDrawable(getResources().getDrawable(R.drawable.open_lock));
            } catch (Exception e) {
                Log.e("openKey", e.toString());
            }
        }
        super.onActivityResult(requestCode, resultCode, data);
    }
MainActivity ->   BluetoothDevice.
 if (BluetoothDevice.ACTION_FOUND.equals(action)) {
                BluetoothDevice receiverDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
                if (isLock(receiverDevice)) {
                    device = receiverDevice;
                }
            }
            bluetooth = new Bluetooth(device, BluetoothUtils.readState());

            bluetooth.connect();
            Thread thread = new Thread(new Runnable() {

                @Override
                public void run() {
                    while (true) {
                        if (BluetoothUtils.isConnect) {
                            try {
                                if (isAutomatic) {
                                    startService(new Intent(MainActivity.this, OpenService.class));
                                    break;
                                }
                            } catch (Exception e) {
                                break;
                            }
                        }
                    }
                }
            });
            thread.start();
        }
MainActivity ->   receiveDevice.
	//查看
	private void receiveDevice() {
        bluetoothAdapter.startDiscovery();
        IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
        receiver = new BluetoothReceiver();
        registerReceiver(receiver, filter);
	} 

Bugs and Feedback

For bugs, questions and discussions please use the Github Issues.

LICENSE

Copyright (c) 2016-present, DuBluetooth Contributors. Author Immqy.com .

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

dubluetooth's People

Contributors

sheep0704 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.