通过连接到外部BLE设备,我能够发送最多20个字节的数据.如何发送大于20个字节的数据.我已经读过,我们必须将数据分段或将特征分割为所需的部分.如果我假设我的数据是32个字节,你能否告诉我需要在我的代码中进行的更改才能使其正常工作?以下是我的代码中所需的代码段:
public boolean send(byte[] data) {
if (mBluetoothGatt == null || mBluetoothGattService == null) {
Log.w(TAG, "BluetoothGatt not initialized");
return false;
}
BluetoothGattCharacteristic characteristic =
mBluetoothGattService.getCharacteristic(UUID_SEND);
if (characteristic == null) {
Log.w(TAG, "Send characteristic not found");
return false;
}
characteristic.setValue(data);
characteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE);
return mBluetoothGatt.writeCharacteristic(characteristic);
}
Run Code Online (Sandbox Code Playgroud)
这是我用来发送数据的代码."发送"功能用于以下onclick事件.
sendValueButton = (Button) findViewById(R.id.sendValue);
sendValueButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String text = dataEdit.getText().toString();
yableeService.send(text.getBytes());
}
});
Run Code Online (Sandbox Code Playgroud)
当String text大于20个字节时,仅接收前20个字节.如何纠正这个?
为了测试发送多个特性我试过这个:
sendValueButton = (Button) findViewById(R.id.sendValue);
sendValueButton.setOnClickListener(new View.OnClickListener() {
@Override
public void …Run Code Online (Sandbox Code Playgroud) 我们如何使用 删除 Android 表中的所有行ContentResolver?
我努力了:
context.getContentResolver().delete(Abcd.CONTENT_URI, null, null);
context.getContentResolver().delete(Abcd.CONTENT_URI, "1", null);
当我给出一个条件时,我知道我的 uri 是正确的:
context.getContentResolver().delete(Channel.CONTENT_URI, "name = ?", "abcd");
该代码有效。
全部删除的正确方法是什么?
现在我正在使用一个 hack:context.getContentResolver().delete(Channel.CONTENT_URI, "name != ?", "");因为名称永远不能为空。
但我想知道最好的方法。
我一直在尝试流式传输URL使用ExoPlayer. 网址:
STREAM_URL_1 = " http://storage.googleapis.com/exoplayer-test-media-0/play.mp3 "
STREAM_URL_2 = " https://s3-ap-southeast-1.amazonaws.com/ok.talk.channels/zakirkhan/Zakir+khan+-+when+my+father+took+my+gf%27s+call.aac "
两个 URL 都可以播放,但我无法获得getDuration()STREAM_URL_2 的 .aac 文件。.mp3 有效。
以下是我的做法。如何获取getDuration()第二个 URL。即使seekTo()如果不工作getDuration()不工作。
我应该做出什么改变?我需要改变任何Extractor吗?
player = ExoPlayer.Factory.newInstance(RENDERER_COUNT, MIN_BUFFER_MS, MIN_RE_BUFFER_MS);
playerControl = new PlayerControl(player);
Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
private static final String STREAM_URL = "http://storage.googleapis.com/exoplayer-test-media-0/play.mp3";
uri = Uri.parse(STREAM_URL);
// Build the video and audio renderers.
DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(player.getMainHandler(),
null);
String userAgent = Util.getUserAgent(this, "MyMediaPlayer");
DataSource dataSource …Run Code Online (Sandbox Code Playgroud) android audio-player android-music-player android-mediaplayer exoplayer
我想开发一个 Android 应用程序,在其中向用户展示带有一些标记的地图。他们根据一个问题选择一个标记,然后将其评估为正确或错误。现在的问题:
这可以通过以下方式实现Google Maps Android API v2:
在 中使用WebViews和谷歌地图WebView:
使用离线地图。
有没有这种可能。我可以在上面放置标记,并知道用户点击的位置吗?
应用程序“地理学习游戏”做得很好,而且底部还写了谷歌,所以他们只使用谷歌地图。http://goo.gl/obE1fB
回答以上任何一个都可以解决我的问题。请用代码回复。