ui-thread

Adding Markers in Background while Looping through ArrayList

ⅰ亾dé卋堺 提交于 2019-11-27 08:01:09
问题 I add Markers to a googleMap from an ArrayList of Objects. There are about 250 markers; I even have to convert them to bitmaps to customize them. It's a pretty resource intensive task. BUT It seriously blocks my UI thread. Here is how I do it: final HashMap<Marker, NearLocation> markerIdMap = new HashMap<Marker, NearLocation>(); for (final NearLocation result : MainActivity.nearLocationList) { // Do all the hard work here } How can I do this somehow dynamically, after the map loads and it

android - calling ui thread from worker thread

耗尽温柔 提交于 2019-11-27 06:36:33
问题 Hi I want to make Toast available to me no-matter-what and available from any thread whenever I like within my application. So to do this I extended the Activity class: import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.widget.Toast; public class MyActivity extends Activity{ private Handler mHandler; @Override public void onCreate(Bundle savedInstanceState) { mHandler = new Handler(); super.onCreate(savedInstanceState); } private class

Run code on UI thread without control object present

你说的曾经没有我的故事 提交于 2019-11-27 01:40:27
问题 I currently trying to write a component where some parts of it should run on the UI thread (explanation would be to long). So the easiest way would be to pass a control to it, and use InvokeRequired/Invoke on it. But I don't think that it is a good design to pass a control reference to a "data/background"-component, so I'm searching for a way to run code on the UI thread without the need of having a control available. Something like Application.Dispatcher.Invoke in WPF... any ideas, thx

Android ViewPager automatically change page

陌路散爱 提交于 2019-11-26 19:30:11
问题 I want to schedule an action to change automatically my ViewPager pages. I've tried: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ... swipeTimer = new Timer(); swipeTimer.schedule(new TimerTask() { @Override public void run() { if (currentPage == NUM_PAGES) { currentPage = 0; } featureViewPager.setCurrentItem(currentPage++, true); } }, 100, 500); but I'm always getting: E/AndroidRuntime(5381): FATAL EXCEPTION: Timer-0 E/AndroidRuntime(5381):

Difference between Handler.post(Runnable r) and Activity.runOnUiThread(Runnable r) [duplicate]

回眸只為那壹抹淺笑 提交于 2019-11-26 16:58:07
问题 This question already has answers here : What's the difference between Activity.runOnUiThread(runnable action) and Handler.post()? (2 answers) Closed last year . Is there a difference between new Handler.post(Runnable r); and activity.runOnUiThread(Runnable r) 回答1: runOnUiThread is basically suited to show a progress dialog or do some UI manipulations before an AsyncTask call. If you want to update the UI in the middle of a thread execution, then the best approach is to create a Handler which

Is it possible to initialize WPF UserControls in different threads?

时间秒杀一切 提交于 2019-11-26 15:49:08
问题 We are developing a WPF application which will open a number of reports at the same time (just like a typical MDI application such as Excel or Visual Studio). Although it is possible to have the data context for those reports run in multiple worker threads, we still find that if the number of opened reports is really big, even the rendering of those reports (basically UserControl hosted either in a MDI environment or just in a grid area in the main view) will still make the application less

Is it possible to use AsyncTask in a Service class?

左心房为你撑大大i 提交于 2019-11-26 13:58:47
问题 Everything is in the title. On the official documentations it is stated that Note that services, like other application objects, run in the main thread of their hosting process and AsyncTask only works if it is executed in the UIThread. So is it possible to use AsyncTask in a Service class? I am trying to do so but I'm always getting the same error 05-01 18:09:25.487: ERROR/JavaBinder(270): java.lang.ExceptionInInitializerError ... 05-01 18:09:25.487: ERROR/JavaBinder(270): Caused by: java

What is the Android UiThread (UI thread)

做~自己de王妃 提交于 2019-11-25 23:21:29
问题 Can someone explain to me what exactly the UI thread is? On developer.android.com it says about the runOnUiThread function public final void runOnUiThread (Runnable action) Since: API Level 1 Runs the specified action on the UI thread. If the current thread is the UI thread, then the action is executed immediately. If the current thread is not the UI thread, the action is posted to the event queue of the UI thread. Does the UI thread mean that this will be run everytime the activity is pushed

How do we use runOnUiThread in Android?

扶醉桌前 提交于 2019-11-25 22:24:31
问题 I\'m new to Android and I\'m trying to use the UI-Thread, so I\'ve written a simple test activity. But I think I\'ve misunderstood something, because on clicking the button - the app does not respond anymore public class TestActivity extends Activity { Button btn; int i = 0; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); btn = (Button)findViewById(R.id.btn); btn.setOnClickListener(new View.OnClickListener() {