草庐IT

thread-bound

全部标签

android - Firebase Android : onDataChange() event always executed in Main UI Thread?

在使用Firebase的Android应用程序中,一旦Firebase返回查询答案,我需要在后台执行长时间操作。例如:query.addListenerForSingleValueEvent(newValueEventListener(){@OverridepublicvoidonDataChange(DataSnapshotdata){dosomethingverylong...thencallacallbackforUIthread}我知道firebase以异步模式执行查询,但onDataChange()方法似乎总是在主UI线程中执行,即使我尝试在自定义后台线程中调用查询.有人知道

java - Android for 循环中的 “Only the original thread that created a view hierarchy can touch its views.” 错误

这个问题在这里已经有了答案:Android"Onlytheoriginalthreadthatcreatedaviewhierarchycantouchitsviews."(33个答案)关闭6年前。我试图每半秒运行一次for循环。每次调用循环时,View中都会发生一些变化,但这些变化是由另一个类(即Speedometer)进行的。Threadthread=newThread(){@Overridepublicvoidrun(){floati;try{for(i=0;i 最佳答案 这是因为任何View只能在主线程或ui线程中修改。尝试

Android Junit 测试失败,出现 "Only the original thread that created a view hierarchy can touch its views."

我对Android非常陌生,正在使用Robotium编写一些基本的Android测试,但失败并出现异常"android.view.ViewRoot$CalledFromWrongThreadException:Onlytheoriginalthreadthatcreatedaviewhierarchycantouchitsviews."下面是基本的测试用例描述:-测试用例:-publicvoidtestSearch(){Activitya=getActivity();SearchItemActivitysearch=newSearchItemActivity(solo);search.

安卓 "speak failed: not bound to tts engine"

我的android应用程序具有文本朗读功能,并且不止一个Activity使用此功能。因此创建了一个静态帮助类来简化此操作。importjava.util.Locale;importandroid.content.Context;importandroid.speech.tts.TextToSpeech;importandroid.speech.tts.TextToSpeech.OnInitListener;importandroid.util.Log;publicclassTextToSpeechControllerimplementsOnInitListener{privatesta

android - toast "sending message to a Handler on a dead thread"

我正在尝试通过Toast显示一条简单的消息,并收到运行时异常“向死线程上的处理程序发送消息”。试图显示Toast消息的类扩展了IntentService。类(C2DMReceiver)实际上来自C2DM的ChromeToPhone示例。方法如下:/***Calledwhenacloudmessagehasbeenreceived.*/@OverridepublicvoidonMessage(Contextcontext,Intentintent){Log.i(LOG_TAG,"Amessagenotificationhasoccuredwiththecloud.");Log.i(LOG

android - Button.setCompoundDrawablesWithIntrinsicBounds() 的左/右填充?

我正在尝试在按钮上设置左图标:setCompoundDrawablesWithIntrinsicBounds(R.drawable.foo,0,0,0);但是图标被放置在我的按钮的左边缘和文本字符串上。有没有办法在提供的图标上指定一些左/右填充,使其不会正好靠在边缘?谢谢 最佳答案 我相信您正在寻找的是android:drawablePadding这是一个使用drawablePadding以及paddingLeft和paddingRight在按钮中定位图像的示例 关于android-Bu

RT-Thread studio使用(持续更新)

文章目录1、RT-Threadstudio下载安装1-1、官网下载安装包:1-2、安装:1-3、注册登录:2、新建RT-Threadnano工程2-1、新建nano工程2-2、连接硬件,下载到板子上测试(选择的是stm32f103c8t6)3、用RT-Threadstudio创建的nano工程的文件解读4、基于RT-Threadnano添加Finsh(实现命令输入)4-1、什么是Finsh4-2、基于Nano添加FinSH(用RT-Threadstudio)5、【问题】怎么用RT-Threadstudio打开已经创建好的RT-Thread项目工程;6、【问题】怎么查找打开指定内容7、【问题】项

android - java.lang.IllegalArgumentException : Rect should intersect with child's bounds

在AndroidStudio中启动一个新项目并选择一个选项卡式Activity后,在项目构建后,我在Android监视器中收到此错误:E/AndroidRuntime:FATALEXCEPTION:mainProcess:com.example.app,PID:23581java.lang.IllegalArgumentException:Rectshouldintersectwithchild'sbounds.atandroid.support.design.widget.CoordinatorLayout.offsetChildByInset(CoordinatorLayout.j

Android 模拟器向 logcat 发送垃圾邮件,内容为“Service com.android.exchange.ExchangeService has leaked ServiceConnection ... that original bound here

我正在开发一个非常简单的Android应用程序。我制作了一个启动画面、主菜单和一个带有单选按钮和一个按钮的页面(根据选中的单选按钮播放声音)。该应用程序工作正常(不会崩溃),但我一直在logcat中遇到所有这些错误(我使用模拟器运行应用程序)。那会是什么?我该如何解决?我应该担心吗?当有人询问时,我会另外发布代码,因为我不知道问题可能出在哪里,并且我不想无缘无故地将所有.java和xml文件发布到垃圾邮件中。logcat中的错误:12-0714:24:28.301:E/ActivityThread(587):Servicecom.android.exchange.ExchangeSer

android - CalledFromWrongThreadException : Only the original thread that created a view hierarchy can touch views

我在Android中遇到以下错误:CalledFromWrongThreadException;:Onlytheoriginalthreadthatcreatedaviewhierarchycantouchitsviews当我尝试在我的Activity中更新Textview时似乎会发生这种情况,更新TextView的调用来self的Activity但我仍然收到上述错误。我是这样的:onCreate()-设置按钮和TextView。onStateChange()-状态更改通知的监听器,当它在TextView更改为说一些不同的文本时收到通知。当我收到新文本的通知时,我尝试将TextView