ui-thread

How to call a RESTful Method from Android?

两盒软妹~` 提交于 2019-12-02 21:36:40
问题 I've tried two different ways to call a simple REST method from Android; said REST method - which works from other clients - simply returns an int val such as 17. Both of the following attempts were based on code I found online. One is like so: public void onFetchBtnClicked(View v){ if(v.getId() == R.id.FetchBtn){ Toast.makeText(getApplicationContext(), "You mashed the button, dude.", Toast.LENGTH_SHORT).show(); new NetworkTask().execute(); } } public static class NetworkTask extends

ProgressDialog not shown in UIThread

╄→гoц情女王★ 提交于 2019-12-02 13:41:44
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() { try{ Log.d("debug", "before setContentView"); //13:36:25 setContentView(R.layout.map); Log.d("debug

Run SurfaceView off UI Thread

核能气质少年 提交于 2019-12-02 07:22:17
问题 My surfraceview is where the majority of my application is and I would like to reduce its lag, thus I have been told to take it off the UI Thread. Is it possible to run a SurfaceView in an AsyncTask? 回答1: While it is possible to draw into a SurfaceView from an AsyncTask it is not recommended. AsyncTasks can run in a serial queue so you would likely block other tasks. Instead just use a Thread. The SDK contains a sample app called LunarLander which shows how to do this. 来源: https:/

Does inline javascript block the UI thread?

给你一囗甜甜゛ 提交于 2019-12-02 04:30:43
问题 I read this nice article on how external scripts block the UI thread but it wasn't clear to me whether the blocking is actually due to the presence of the <script> tag or the src='/myscript.js' src attribute. My question is does inline javascript (lacking a src attribute declaration), for example this: <script type='text/javascript'> alert('am i blocking too?');</script> or this: <script type='text/javascript'> var php='<?=json_encode($myObj)?>';</script> also block the UI thread? 回答1: Any

Why cant a thread that is not the UI thread access the view?

人走茶凉 提交于 2019-12-02 04:06:52
问题 I know that no thread can access the current view unless it is the UI Thread. I am wondering why? Why does it matter which thread is changing the view? Is it a security reason? This is the work around I use: public void doLayout() { Runnable run = new Runnable() { public void run() { ViewerActivity.setContentView(R.layout.main); } }; handler.post(run); } private Handler handler;' It is kind of a pain to do that everytime i want to change the layout. Is there a different work around? I know

Run SurfaceView off UI Thread

。_饼干妹妹 提交于 2019-12-02 03:16:05
My surfraceview is where the majority of my application is and I would like to reduce its lag, thus I have been told to take it off the UI Thread. Is it possible to run a SurfaceView in an AsyncTask? While it is possible to draw into a SurfaceView from an AsyncTask it is not recommended. AsyncTasks can run in a serial queue so you would likely block other tasks. Instead just use a Thread. The SDK contains a sample app called LunarLander which shows how to do this. 来源: https://stackoverflow.com/questions/15489571/run-surfaceview-off-ui-thread

F# cross-thread UI exception in WinForms App

扶醉桌前 提交于 2019-12-02 00:12:29
问题 I have a problem with developing a simple application in F#, which just reads the length of the requested HTML page. Seems to be that such an error would be similar for VB.NET/C# language too, when you develop the UI application. But I'm rather new to F# and don't really imagine hot to fix such issue exactly in F#. Source code in F#: http://pastebin.com/e6WM0Sjw open System open System.Net open Microsoft.FSharp.Control.WebExtensions open System.Windows.Forms let form = new Form() let text =

Is SQL or general file access appropriate in the Android main UI thread?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 04:31:24
I'm trying to follow Android best practices, so in debug mode I turn all the following on: StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build()); //detect and log all thread violations StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build()); //detect and log all virtual machine violations Android now yells at me when I try to use any sort of file access or SQL in the main (UI) thread. But I see so many recommendations to use file access and/or SQL in the main thread. For example, the main activity should load

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

∥☆過路亽.° 提交于 2019-12-01 02:44:57
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 doing processing. This function also falls into this net. But I don't want it to block up the UI thread.

Interacting with the UI thread from an Async callback method?

主宰稳场 提交于 2019-12-01 01:28:14
I have a method that is asynchronously called when System.Net.Sockets.NetworkStream.BeginRead completes. skDelegate = New AsyncCallback(AddressOf skDataReceived) skStream.BeginRead(skBuffer, 0, 100000, skDelegate, New Object) In that callback method, I need to interact with the UI thread. Sub skDataReceived(ByVal result As IAsyncResult) CType(My.Application.OpenForms.Item("frmMain"), frmMain).refreshStats(d1, d2) End Sub This causes an exception after the method completes. (when End Sub is executed) The Undo operation encountered a context that is different from what was applied in the