用于测试的设备:Nexus 4,Android 4.3
连接工作正常,但onCharacteristicChanged我的回调方法永远不会被调用.但是我正在使用setCharacteristicNotification(char, true)inside 注册通知onServicesDiscovered,该函数甚至返回true.
设备日志(当通知应该出现/通过蓝牙设备发送时,实际上根本没有消息):
07-28 18:15:06.936 16777-16809/de.ffuf.leica.sketch D/BluetoothGatt: setCharacteristicNotification() - uuid: 3ab10101-f831-4395-b29d-570977d5bf94 enable: true
07-28 18:15:06.936 4372-7645/com.android.bluetooth D/BtGatt.GattService: registerForNotification() - address=C9:79:25:34:19:6C enable: true
07-28 18:15:06.936 4372-7645/com.android.bluetooth D/BtGatt.btif: btif_gattc_reg_for_notification
07-28 18:15:06.946 4372-7645/com.android.bluetooth D/BtGatt.btif: btgattc_handle_event: Event 1018
07-28 18:15:06.946 4372-7645/com.android.bluetooth D/BtGatt.GattService: onRegisterForNotifications() - address=null, status=0, registered=1, charUuid=3ab10101-f831-4395-b29d-570977d5bf94
07-28 18:15:06.946 4372-7645/com.android.bluetooth D/BtGatt.btif: btgattc_handle_event: Event 1016
07-28 18:15:06.946 4372-7645/com.android.bluetooth D/BtGatt.btif: btgattc_handle_event: Event 1018
07-28 18:15:06.946 4372-7645/com.android.bluetooth D/BtGatt.GattService: onRegisterForNotifications() - address=null, status=0, …Run Code Online (Sandbox Code Playgroud) android bluetooth bluetooth-lowenergy gatt android-4.3-jelly-bean
如何限制TextBox仅接受大写字母,例如数字,或禁止放置任何特殊字符?
当然,抓住TextInput事件并在此处理文本是一块蛋糕,但这是否是正确的方法呢?
这个属性使
"短而长的字"
至
"短而且"
.但是我想要成功.喜欢
"短暂而且非常......"
现在我在Java代码中截断String.但是,那基于字符数而不是链接的实际长度.所以,结果不是很好.
String title;
if(model.getOrganization().length() > 19) {
title = model.getText().substring(0, 15).trim() + "…";
} else {
title = model.getText();
}
((TextView) findViewById(R.id.TextViewTitle)).setText(title);
Run Code Online (Sandbox Code Playgroud)
更新
刚刚注意到,这个属性实际上在一些情况下添加了"......".但不是全部:
12345678901234567890成为"12345678901234 ......"
然而,
"1234567890 1234567890"变为"1234567890"而不是"1234567890 123 ......"
更新2
现在真的很时髦!我只是设置了singleLine = true并删除了maxLine(这个bug出现时带有和不带有ellipsize属性)...

这是摩托罗拉Milestone与Android 2.1更新1的截图.在HTC Desire上使用相同的Android版本也是如此
更新3
现在我使用android:ellipsize ="marquee".这似乎是唯一正常工作的环境.只有集中注意力时它才会移动.我也在许多其他应用程序中看到它.我想这是常见的做法.
我在Nexus 4上新推出的Android 4.3 BLE API上使用startLeScan(新UUID [] {MY_DESIRED_128_BIT_SERVICE_UUID},回调)时遇到问题.
回调就是没有被调用.我仍然可以在日志中看到传入的包:
08-02 15:48:57.985: I/bt-hci(1051): btu_ble_process_adv_pkt
08-02 15:48:58.636: I/bt-hci(1051): BLE HCI(id=62) event = 0x02)
Run Code Online (Sandbox Code Playgroud)
如果我不使用该参数来过滤UUID,它可以工作.我们使用制造商特定的128位UUID作为我们公司的设备.
现在,我们的设备提供的服务比我在阵列中提供的服务更多.但那应该不是问题.
有人面临同样的问题吗?有解决方案吗
编辑
有几个与扫描有关的问题,这个问题只讨论一个问题:如果您还有扫描问题,请先阅读此评论.还要记住,我的设备强加了16位和128位UUID.大多数人都使用BLE标准提供的16位UUID,如Heart rate或Speed and Cadence.
将Android Studio从3.0更新到3.1后我的项目gradle同步失败,出现以下错误.
Gradle sync failed: Uninitialized object exists on backward branch 70 Exception Details: Location:
com/android/build/gradle/tasks/BuildArtifactReportTask.newArtifact(Lcom/android/build/api/artifact/BuildableArtifact;)
Lcom/android/build/gradle/tasks/BuildArtifactReportTask$BuildableArtifactData;
Run Code Online (Sandbox Code Playgroud) 我想实现一个通用的线程保存类,它接受ImageView的RessourceId和存储所需图像文件的Url(http).它将下载图像并在UiThread中填充ImageView的src.
我认为AsyncTask对我来说是最好的.但是我注意到我只能将一种类型的参数传递给doInBackground()Method.就像一个Urls数组.真的吗?你会建议我什么?
我使用 Layout_width="fill_parent"和Layout_height="wrap content".如果图像比ImageView大,它将完全缩小尺寸.
但是,我从来没有努力升级较小的图像.我尝试了ScaleType和"AdjustViewBounds"的任意组合:它总是在图像视图的中间保持自己的大小.这是代码......
<LinearLayout
android:id="@+id/LinearLayout02"
android:layout_height="wrap_content"
android:background="@drawable/content_bg"
android:orientation="vertical"
android:padding="5dp"
android:layout_width="fill_parent"
android:layout_marginLeft="1px">
<ImageView
android:layout_height="wrap_content"
android:src="@drawable/test"
android:id="@+id/ImageViewTest"
android:layout_width="fill_parent"
android:adjustViewBounds="true"
android:scaleType="center"></ImageView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我正在开发一个Android应用程序并通过确定系统首次启动时间来解决问题.我的意思是我需要测量设备首次启动时已经过了多少时间.
我知道有关侦听ACTION_BOOT_COMPLETED的解决方案并在SharedPreferences中保存任何内容,但我需要另一个解决方案,因为这个解决方案在某些情况下不起作用.也许有任何系统属性?
用例(摘自讨论)
System.currentMillis()解决这个问题的银弹将是一个时间戳,它计算自首次启动(出厂重置后)后的秒数.就像SystemClock.elapsedRealtime()每次启动后没有重置一样.不幸的是,到目前为止的答案告诉我们,这个银弹不存在.
但是,许多答案显示了如何解决这个问题的各种选择.OneWorld123评论了每个答案,如何满足他的需求.
LogCat输出下面有一个TextField"Filter".但是,它似乎只过滤了Message-column.我也喜欢过滤标签.因为有我的班级名字.
我怎样才能实现它?
我不想编码已经存在的东西......