ui-thread

ProgressDialog not shown in UIThread

泄露秘密 提交于 2019-12-31 05:16:06
问题 I'm creating a map using the google api lib. Because the mapwidget takes a long time to load I'm trying to add a loading notification, but it isn't shown. I can show the progressDialog in regular threads though. How come this dialog isn't shown? public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); progressDialog = ProgressDialog.show(this, "Please Wait", "Map = loading",false,true); //setContentView(R.layout.map); runOnUiThread(new Runnable(){ public void run(

How to execute some code in Android UI thread async?

醉酒当歌 提交于 2019-12-30 17:39:10
问题 I'm new to Android development. I've be working on Swing and SWT for several years. Both Swing and SWT has a stratage to execute code in UI thread sync and async. The typical usage is doing some time-consume staff in one thread then display the result in UI thread async. So my question is, is there similiar stratage in Android? Here is my code. Parameter runnable is some time-consume code. This method will display a waiting dialog during the execution then EXPECT to show a Toast after it is

How to detect if we're on a UI thread?

本秂侑毒 提交于 2019-12-30 08:01:53
问题 For the sake of argument, consider a UI thread as a thread that has had a call to Application.Run() or one of it's overloads called on it and has an active message loop running. Is there a way of detecting if we're currently executing on such a thread? The reason I want this is because I have a class with a private function that is long-running. The class itself is already multithreaded, and the usage of this class is such that it might be used from either the UI or from background threads

How will UI changes be processed in the onClickListener before starting a new activity in Android?

依然范特西╮ 提交于 2019-12-25 06:38:22
问题 I have been searching here in this forum but I cannot find any answer to my question. I have the following problem: I have a imageview and two texts, and I want to change the color on selection to show show visual feedback before loading the next activity. @Override public void onClick(View v) { openFormOverviewButton.setColorFilter(0x22FFFFFF, Mode.SRC_ATOP); openFormOverviewTitle.setTextColor(0xFF00851B); openFormOverviewText.setTextColor(0xFF00851B); Intent tki = new Intent(); tki.setClass

UI freezes when using SystemEvents.UserPreferenceChanged and multiple UI threads

落花浮王杯 提交于 2019-12-25 03:52:30
问题 In my C# Windows Forms application there are two threads: Main Thread (Program.cs) WorkerClass Thread (STA-Apartment). When there is long running Task, it freeze/stuck the entire process and No exception or notification fired..it hangs application. Internally applications doing processing of records only (selection from SQL tables & inserting in Access DB tables) UI updates will be done using event Action feature. Find attached snap for stuck process parallel tasks. Seems like threads

Android TextView text is showing up as black squares?

…衆ロ難τιáo~ 提交于 2019-12-25 02:44:17
问题 I have a TextView in my application that works fine until I pause the application (by pressing home) and launch it again. It should just resume the activity, but for some reason the TextView doesn't display the text properly after it resumes the activity. The text is showing up as black squares, like this: http://i.stack.imgur.com/5mtvy.png Does anyone know how to fix this? EDIT: Here's my code: The TextView is created in a layout xml that has a GLSurfaceView (called GameView) and on top of

ASynchTask sleep in doinbackground locking the UI thread

我的未来我决定 提交于 2019-12-25 01:45:56
问题 EDIT: SOLVED. Sorry guys, it occurred to me that while my loading of my data was occurring in a background thread, the callback that parsed the data was not. The parsing of the data took a very long time, and that was what was locking my thread. EDIT: It has come to my attention that my overarching problem (the ProgressDialog no longer spinning) may be caused by a problem with my use of a ProgressDialog rather than the UI thread being blocked. If that is the case, how do I fix that? EDIT: to

Using Invoke to handle calls from other threads. Is this a good pattern?

谁说胖子不能爱 提交于 2019-12-24 13:42:50
问题 After reading up on how to use Invoke to be able to update GUI elements from other threads I worked a bit with it, and has ended up with following approach to handle it. I am fairly certain I have overcomplicated the solution, but I do believe it is working as intended. The advantages I see with this approach is, that it allows multiple commands to be stored in short succession for consumption once the GUI thread is ready for it, and the order of the commands are maintained. The downside is

Android UI Thread Block when calling AsynchTask.get()

一个人想着一个人 提交于 2019-12-24 06:58:35
问题 My activity is a login page. When the user clicks, an asyncTask check in a database if credentials are good. During the task, I want to display a ProgressDialog but after clicking on the button, it stays pressed for 5 seconds and then my ProgressDialog quiclky shows up (less than 1 second) and the toast appears. There is my onClick function : Button connect = (Button)findViewById(R.id.connectButton); final EditText loginED = (EditText) findViewById(R.id.login); final EditText passwordED =

Let ScheduledThreadPoolExecutor execute tasks on UI thread

穿精又带淫゛_ 提交于 2019-12-24 03:23:36
问题 How can I use a ScheduledThreadPoolExecutor and schedule a task which is always executed on the UI thread? Currently, I do the following mScheduledTask = sBackgroundExecutor.scheduleAtFixedRate(new Runnable() { @Override public void run() { if (mActivity != null) { mActivity.runOnUiThread(new Runnable() { @Override public void run() { // do UI stuff } }); } } }, 0, 200, TimeUnit.MILLISECONDS); This seems unnecessary and hard to read, but I couldn't find anything in the docs. Is it possible or