So I have main UI thread and there is a function that takes quite some time. So I want to show user something on the screen for that time, but I don't want to mve my function in to the thread because it neads some GUI communication.

so what I need is this

Message msg;
msg.wait("wait dude");
//my code
msg.dismis_wait();

Any ideas?

I tried putting my code into thread but there is a problem that at the end of code I need to change my view, and I cannot do that from thread.

that's actual the best answer, the asynctack did the trick. because of it's postexecute method, btw can i do that in thread?
–
gabrjanSep 24 '12 at 11:46

@gabrjan If I understand you correctly, yes you can do it with a regular Thread. You can use Handler, which is a mechanism for sending messages. That way, when you finish your thread execute, you can send a message with success or unsuccess signal and update the screen respectively. The message can be sent with sendEmptyMessage method, with a number that symbols operation ended successfully or not.
–
Ofir A.Sep 24 '12 at 12:50

if i use toast there is a problem that at the start when i write Toast.makeText(Main.this, " Here you message ", Toast.LENGTH_LONG).show(); is not showed until all code goes trough. I know that0s weird but that0s how it is :S so if i change view at the end it doesn't show at all :S
–
gabrjanSep 24 '12 at 10:29

Show toast message when accessing onCreate method for example. If you have long time process code, you should think about running it in the thread.
–
hszSep 24 '12 at 10:32

i have a function that takes about 15 sec and for that time i want to show some stuf on screen...
–
gabrjanSep 24 '12 at 10:38

after starting Timer show your message an onFinish of CountDownTimer dismiss message.
You can change the values at object creation time. The first value i.e. "15000" is the total time in millisecs and second value i.e. "1000" is time per tick in millisecs.

@gabrjan: Ofir A has suggested the correct solution for ur query. Never run the long/cpu intensive operations in the main thread. Use an AsyncTask/Thread to perform ur backend operation and use handler instance to post the ui updation. U can also go with runOnUiThread for updating ur UI.

if i use toast there is a problem that at the start when i write Toast.makeText(Main.this, " Here you message ", Toast.LENGTH_LONG).show(); is not showed until all code goes trough. I know that0s weird but that0s how it is :S
–
gabrjanSep 24 '12 at 10:28

@Gabrjan: Put your entire code inside a scheduleTaskExecutor. That one runs code in the background line by line. so you can show your toast message in the beginning. see my edit above.
–
SunnySonicSep 24 '12 at 11:06