ContentProvider insert() always runs on UI thread?

随声附和 提交于 2019-11-28 03:34:27

Instead of calling mContentResolver.insert(), use AsyncQueryHandler and its startInsert() method. AsyncQueryHandler is designed to facilitate asynchronous ContentResolver queries.

Ellen Spertus

I think your original problem may have been that you are calling the run method on your new thread (which causes execution to continue on the current thread) instead of calling the start method. I think this is what Bright Great was trying to say in his/her answer. See Difference between running and starting a thread. It's a common mistake.

Man.Relax yourself.And anything would looks better. At first,Start a Thread is Func start not Func run,if you want to start the new Thread not only call the func run.

new Thread(Runnable runnable).start();

Then I bet use Handler sometimes would be better than AsyncTask.

shivin satyan

You can run the query in the doInBackground(Integer int) overridden method of the AsynTask, and update the main UI on the onPostExecute(Integer int) method.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!