java - Ending an activity on a background thread -
I assume that it will call According to the answer to this type of question, using a handler, the UI thread is appropriate. I tried to do this but the activity never ended - should I do something before posting, or what Should I use a completely different method? By default, the handler (looper) is created on the thread which is installed on them. To ensure that the handler is on the main UI thread, you can: Then, to post the item on the main thread, create a class that executes the Another easy grandma move you can post on a Some things to note about all the things posted on the UI thread will be displayed. to end () on one activity from a thread Poor practice is not UI threads I need to end an activity when a certain event (rendering / loop is calculated in the thread).
handler myHandler = new handler (Looper.getMainLooper ());
Runnable interface, then post to the handler
myHandler.post (new Runnabel) {@Override public void run ()} {code to run on UI code}}});
view which is visible to your activity. For example, see your root view
MyView = findViewById (R.id.myViewId); Runnabal Runnabalject = New MyRunnableObject (); MyView.post (runnableObject);
view , and then they can all see the
view by checking the user. It should also be noted that this is not particularly easy to cancel
Runnable s which are posted in the view. They internally use a handler, but remove
____ () methods are completely all.
Comments
Post a Comment