activity.runOnUiThread()内的run()方法没有被执行


activity.runOnUiThread(new Runnable() {
                public void run()
                {
                    Toast.makeText(context, toast, Toast.LENGTH_SHORT).show();
                }
            });

run()方法没有执行,查找原因,在原来,掉用runOnUiThread的activity,一定得是Activity对象,so,在使用之前,需要增加判读:
if(activity instanceOf Activity){

}

参考链接


原文:

It doesn't always work, you have to be sure that what you are casting is
effectively an Activity or you'll have a ClassCastException. To do that you can do
"if(context instanceOf Activity){ // proceed to cast }"

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM