Android进阶资料
以下的资料是近年来,我和一些朋友面试收集整理了很多大厂的面试真题和资料,还有来自如阿里、小米、爱奇艺等一线大厂的大牛整理的架构进阶资料。希望可以帮助到大家。
Android进阶核心笔记
百万年薪必刷面试题
最全Android进阶学习视频
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
- 扫描指定设备名称的设备
//该方式是扫到指定设备就停止扫描
ViseBle.getInstance().startScan(new SingleFilterScanCallback(new IScanCallback() {
@Override
public void onDeviceFound(BluetoothLeDeviceStore bluetoothLeDeviceStore) {
}
@Override
public void onScanFinish(BluetoothLeDeviceStore bluetoothLeDeviceStore) {
}
@Override
public void onScanTimeout() {
}
}).setDeviceName(deviceName));
- 扫描指定 UUID 的设备
ViseBle.getInstance().startScan(new UuidFilterScanCallback(new IScanCallback() {
@Override
public void onDeviceFound(BluetoothLeDeviceStore bluetoothLeDeviceStore) {
}
@Override
public void onScanFinish(BluetoothLeDeviceStore bluetoothLeDeviceStore) {
}
@Override
public void onScanTimeout() {
}
}).setUuid(uuid));
- 扫描指定设备 MAC 或名称集合的设备
ViseBle.getInstance().startScan(new ListFilterScanCallback(new IScanCallback() {
@Override
public void onDeviceFound(BluetoothLeDeviceStore bluetoothLeDeviceStore) {
}
@Override
public void onScanFinish(BluetoothLeDeviceStore bluetoothLeDeviceStore) {
}
@Override
public void onScanTimeout() {
}
}).setDeviceMacList(deviceMacList).setDeviceNameList(deviceNameList));
- 扫描指定信号范围或设备正则名称的设备
ViseBle.getInstance().startScan(new RegularFilterScanCallback(new IScanCallback() {
@Override
public void onDeviceFound(BluetoothLeDeviceStore bluetoothLeDeviceStore) {
}
@Override
public void onScanFinish(BluetoothLeDeviceStore bluetoothLeDeviceStore) {
}
@Override
public void onScanTimeout() {
}
}).setDeviceRssi(rssi).setRegularDeviceName(regularDeviceName));
其中扫描到的设备列表由 BluetoothLeDeviceStore
管理,而单个设备信息都统一放到BluetoothLeDevice
中,其中包含了设备的所有信息,如设备名称、设备地址、广播包解析信息等,设备的相关信息会在设备详情中进行介绍。
设备连接
设备连接有三种方式,一种是根据设备信息直接进行连接,另外两种是在没扫描的情况下直接通过设备名称或设备 MAC 进行扫描连接。三种连接方式使用如下:
- 根据设备信息连接设备
ViseBle.getInstance().connect(bluetoothLeDevice, new IConnectCallback() {
@Override
public void onConnectSuccess(DeviceMirror deviceMirror) {
}
@Override
public void onConnectFailure(BleException exception) {
}
@Override
public void onDisconnect(boolean isActive) {
}
});
- 根据设备 MAC 直接扫描并连接
ViseBle.getInstance().connectByMac(deviceMac, new IConnectCallback() {
@Override
public void onConnectSuccess(DeviceMirror deviceMirror) {
}
@Override
public void onConnectFailure(BleException exception) {
}
@Override
public void onDisconnect(boolean isActive) {
}
});
- 根据设备名称直接扫描并连接
ViseBle.getInstance().connectByName(deviceName, new IConnectCallback() {
@Override
public void onConnectSuccess(DeviceMirror deviceMirror) {
}
@Override
public void onConnectFailure(BleException exception) {
}
@Override
public void onDisconnect(boolean isActive) {
}
});
设备详情
DEVICE INFO(设备信息)
- 获取设备名称(Device Name):
bluetoothLeDevice.getName()
; - 获取设备地址(Device Address):
bluetoothLeDevice.getAddress()
; - 获取设备类别(Device Class):
bluetoothLeDevice.getBluetoothDeviceClassName()
; - 获取主要设备类别(Major Class):
bluetoothLeDevice.getBluetoothDeviceMajorClassName()
; - 获取服务类别(Service Class):
bluetoothLeDevice.getBluetoothDeviceKnownSupportedServices()
; - 获取配对状态(Bonding State):
bluetoothLeDevice.getBluetoothDeviceBondState()
;
RSSI INFO(信号信息)
- 获取第一次信号时间戳(First Timestamp):
bluetoothLeDevice.getFirstTimestamp()
; - 获取第一次信号强度(First RSSI):
bluetoothLeDevice.getFirstRssi()
; - 获取最后一次信号时间戳(Last Timestamp):
bluetoothLeDevice.getTimestamp()
; - 获取最后一次信号强度(Last RSSI):
bluetoothLeDevice.getRssi()
; - 获取平均信号强度(Running Average RSSI):
bluetoothLeDevice.getRunningAverageRssi()
;
SCAN RECORD INFO(广播信息)
根据扫描到的广播包AdRecordStore
获取某个广播数据单元AdRecord
的类型编号record.getType()
,再根据编号获取广播数据单元的类型描述record.getHumanReadableType()
以及该广播数据单元的长度及数据内容,最后通过AdRecordUtil.getRecordDataAsString(record)
将数据内容转换成具体字符串。更多关于广播包解析可以参考Android BLE学习笔记中数据解析部分。
发送数据
在发送数据前需要先绑定写入数据通道,绑定通道的同时需要设置写入数据的回调监听,具体代码示例如下:
BluetoothGattChannel bluetoothGattChannel = new BluetoothGattChannel.Builder()
.setBluetoothGatt(deviceMirror.getBluetoothGatt())
.setPropertyType(PropertyType.PROPERTY_WRITE)
.setServiceUUID(serviceUUID)
.setCharacteristicUUID(characteristicUUID)
.setDescriptorUUID(descriptorUUID)
.builder();
deviceMirror.bindChannel(new IBleCallback() {
@Override
public void onSuccess(byte[] data, BluetoothGattChannel bluetoothGattChannel, BluetoothLeDevice bluetoothLeDevice) {
}
@Override
public void onFailure(BleException exception) {
}
}, bluetoothGattChannel);
deviceMirror.writeData(data);
这里的 deviceMirror 在设备连接成功后就可以获取到,需要注意的是,服务一样的情况下写入数据的通道只需要注册一次,如果写入数据的通道有多个则可以绑定多个。写入数据必须要在绑定写入数据通道后进行,可以在不同的地方多次写入。
接收数据
与发送数据一样,接收设备发送的数据也需要绑定接收数据通道,这里有两种方式,一种是可通知方式、一种是指示器方式,使用方式如下:
- 可通知方式
BluetoothGattChannel bluetoothGattChannel = new BluetoothGattChannel.Builder()
.setBluetoothGatt(deviceMirror.getBluetoothGatt())
.setPropertyType(PropertyType.PROPERTY_NOTIFY)
.setServiceUUID(serviceUUID)
.setCharacteristicUUID(characteristicUUID)
.setDescriptorUUID(descriptorUUID)
.builder();
deviceMirror.bindChannel(new IBleCallback() {
@Override
public void onSuccess(byte[] data, BluetoothGattChannel bluetoothGattChannel, BluetoothLeDevice bluetoothLeDevice) {
}
@Override
public void onFailure(BleException exception) {
}
}, bluetoothGattChannel);
deviceMirror.registerNotify(false);
- 指示器方式
BluetoothGattChannel bluetoothGattChannel = new BluetoothGattChannel.Builder()
.setBluetoothGatt(deviceMirror.getBluetoothGatt())
.setPropertyType(PropertyType.PROPERTY_INDICATE)
.setServiceUUID(serviceUUID)
.setCharacteristicUUID(characteristicUUID)
.setDescriptorUUID(descriptorUUID)
.builder();
deviceMirror.bindChannel(new IBleCallback() {
@Override
public void onSuccess(byte[] data, BluetoothGattChannel bluetoothGattChannel, BluetoothLeDevice bluetoothLeDevice) {
}
@Override
public void onFailure(BleException exception) {
}
}, bluetoothGattChannel);
deviceMirror.registerNotify(true);
在绑定通道后需要注册通知,并需要在收到注册成功的回调时调用如下代码设置监听:
deviceMirror.setNotifyListener(bluetoothGattInfo.getGattInfoKey(), new IBleCallback() {
@Override
public void onSuccess(byte[] data, BluetoothGattChannel bluetoothGattChannel, BluetoothLeDevice bluetoothLeDevice) {
}
@Override
public void onFailure(BleException exception) {
}
});
所有设备发送过来的数据都会通过上面的监听得到,如果不想监听也可以取消注册,使用方式如下:
deviceMirror.unregisterNotify(isIndicate);
最后
今天关于面试的分享就到这里,还是那句话,有些东西你不仅要懂,而且要能够很好地表达出来,能够让面试官认可你的理解,例如Handler机制,这个是面试必问之题。有些晦涩的点,或许它只活在面试当中,实际工作当中你压根不会用到它,但是你要知道它是什么东西。
最后在这里小编分享一份自己收录整理上述技术体系图相关的几十套腾讯、头条、阿里、美团等公司2021年的面试题,把技术点整理成了视频和PDF(实际上比预期多花了不少精力),包含知识脉络 + 诸多细节,由于篇幅有限,这里以图片的形式给大家展示一部分。
还有 高级架构技术进阶脑图、Android开发面试专题资料,高级进阶架构资料 帮助大家学习提升进阶,也节省大家在网上搜索资料的时间来学习,也可以分享给身边好友一起学习。
【算法合集】
【延伸Android必备知识点】
【Android部分高级架构视频学习资源】
**Android精讲视频领取学习后更加是如虎添翼!**进军BATJ大厂等(备战)!现在都说互联网寒冬,其实无非就是你上错了车,且穿的少(技能),要是你上对车,自身技术能力够强,公司换掉的代价大,怎么可能会被裁掉,都是淘汰末端的业务Curd而已!现如今市场上初级程序员泛滥,这套教程针对Android开发工程师1-6年的人员、正处于瓶颈期,想要年后突破自己涨薪的,进阶Android中高级、架构师对你更是如鱼得水,赶快领取吧!
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
上初级程序员泛滥,这套教程针对Android开发工程师1-6年的人员、正处于瓶颈期,想要年后突破自己涨薪的,进阶Android中高级、架构师对你更是如鱼得水,赶快领取吧!
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!