How to show 'please wait' and avoid GUI hang ?

I wrote application that contain 2 activities. In the first one - i need to give the user the option to choose image from the gallery and i send this image to some server. The Server return some result - and if the result is OK i need to show the second activity.

The problem that i have ..

  1. when sending the image - i see that the screen is become black ... I want to avoid this and show some nice GUI of 'please wait' - how can i do it ?
  2. i want to make this sending image to the server to be from other thread - how can i do it from android ? how to define new thread with callback that will be called when the thread is done ?

Thanks for any help.

-------------Problems Reply------------

For question number 1:

You should use a ProgressDialog or a ProgressBar in order to show to the user that an operation is being executed. For more information you can check here:

For question number 2: A good solution would be to use AsyncTask for this operation which gives you a set of callback functions to control the operation. For more information you can check here:

Hope this helps for now!

Use an asynctask. It would go something like this:

public void sendImage() {

protected class SendToServer extends AsyncTask<Void, Boolean, Void>

protected void onPreExecute()
//display your dialog

protected Boolean doInBackground(Void... arg0) {

//code to send your image to the serve

protected void onPostExecute (Boolean updateSuccess)
//close your dialog
//If image was successfully sent open your other activity

  1. you can define your custom layout and use the Activity.setContentView method to put whatever you want in your GUI. For instance you can put a ProgressBar widget.

  2. As you have noticed, you wrote your android app in Java SE. Thread are fully supported.

This question has an answer which addresses the problem. Use that answer as a start, and let us know if you have any problems with some specific part.

Download image for imageview on Android

Good luck

Category:android Views:7 Time:2011-12-18
Tags: android

Related post

  • Why Ruby 1.9 GUI hangs if i do any intensive computation in separate Ruby thread? 2012-01-30

    Ruby 1.9 is supposed to have native threads, and GIL is supposed to lift if some threads enters native code (like GUI toolkit main loop or C implementation of some Ruby lib). But if i start following simple code sample that displays GUI in main threa

  • How to Avoid Gui Lock 2009-10-16

    I'm developing a Desktop application. I have a button that upon click calls some webservices. Problem is when there is no connection or on a slow connection the interface becomes unresponsive and it seems as if the application crashed. Wonder what ar

  • NSURLConnection, tableview GUI hangs 2011-05-09

    I am showing the images in the tableview using NSData dataWithContentsOfURL method but when i scroll the tableview GUI gets after searching over the forum i found that i can try with NSUrlConnection method. so i tried but i cant implement i

  • Windows Forms GUI hangs when calling OpenFileDialog.ShowDialog() 2011-07-16

    my project a three tier architecture project talking to a WCF service in the backend. When the backend is able to fetch data from the service, it notifies the business layer using publish-subscribe, which in return notifies the GUI layer. I have adde

  • Create Java console inside a GUI panel 2008-12-05

    How can I create an instance of the Java console inside of a GUI panel? --------------Solutions------------- Here's a functioning class. You can install an instance of this into the system out and err using: PrintStream con=new PrintStream(new TextAr

  • Is Java the best language to develop cross-platform GUI applications? 2008-12-23

    For "best" I intend that the code shouldn't need, or need very few, platform specific tweaks. --------------Solutions------------- I strongly recommend Java for cross-platform GUI development. In particular, I recommend the GUI builder that comes wit

  • Simple GUI scripting question 2010-08-13

    I am trying this simple GUI script to open a new window of Safari: tell application "Safari" activate end tell tell application "System Events" tell process "Safari" try tell menu bar 1 tell menu bar item 3 click menu item 1 end tell end tell on erro

  • In Java,Is it a good practice to make GUI(Swings) using GUI builders or by hand-coding? 2010-12-05

    Possible Duplicate: Java, GUI builder or hand coding? I have been making GUI hand-coded for several apps.But some of my pals are using GUI builders like netbeans IDE.I too tried it recently but the amount of code produced for a simple GUI(around 2 pa

  • GUI Locking up when using PrintDialog and PrintPreviewDialog in .net 2008-12-05

    I'm using .net's PrintPreviewDialog and whenever it's generating a preview, it locks up my GUI in the background and makes it look like it has crashed until the preview is finished. Seeing how the .net's page progress window that pops up isn't a dial

  • Database access in GUI thread , bad isn't it? 2009-06-23

    I'm working through some MSDN examples, and some books on ADO.Net. What they all have in common is using the point/click/drag-drop design time feature in Visual Studio to develop database applications, binding data sets to controls etc. And the resul

  • Why does my GUI still hang even after using SwingUtilities.invokeLater? 2010-11-19

    I have this ActionListener that gets called in the EDT. My plot() function is computationally heavy, it can easily take five seconds. It made the GUI hang as expected. I added the SwingUtilities.invokeLater code and it still hangs. Shouldn't the GUI

  • MacOSX: avoid hang when getting current directory of Finder via AppleScript 2011-03-14

    Currently I am using this AppleScript to get the current directory of Finder: tell application "Finder" return POSIX path of ((folder of the front window) as text) end tell When you run this quite often, e.g. put it into a file and run while true; do

  • GUI is non responsive while updating grid having 80 columns during heavy update 2011-06-23

    I am having an application which is for securities trading in stock exchange. It has real time market feed from one of the vendors. We are processing market data on worker thread(s) and while updating main GUI we are marshaling this data to GUI threa

  • Problems with Backgroundworker, GUI is hanged 2011-12-05

    I am using a background worker below an a form, and when i click a button it should generate a document, but the GUI hangs , i don't know why it does that, because i feel i m using the backgroundworker right.. can anybody helps in this ? private void

  • how to avoid application not responding while net is disconnected in android 2012-04-13

    i create login page . this login page validate from server database .if net is available mean if click login button means it works fine . if i disable net then click login button means it shows error the application was not responding .. how to avoid

  • How can I implement OutlookApp.Onquit Event with redemption on delphi and Avoid Hung outlook when app is busy 2012-05-02

    I want to prompt a user when outlook is getting closed. I am already using redemption with my application. I dont want to use TOutlookApplication Class which provided with Delphi. Kindly help me to implement Outlook Onclose/OnQuit event on Delphi. Wh

  • VB.NET: Is there a way to reduce the lag of loading a huge list of text lines to a listbox? 2009-05-27

    I am using file.readalllines to read the file into a string, then using listbox.items.addrange and splitting by vbcrlf to insert the items. Is there a way to reduce the lag it causes for loading huge lists? --------------Solutions------------- Given

  • Scheduled tasks (Timers) in Swing 2010-12-23

    A GUI using Swing, must update part of its UI from a every 5 seconds. (output.setPage(url)) The code is running in a timer, but on every update, the GUI hangs. How do I avoid making the UI hang? Here is my code: <insert code here> -------------

  • Petri net drawing and code generation 2011-02-09

    Is there any software for drawing a Petri net and generating any source code from there? The source code could be in any already known programming language... Slightly less desirable option would be outputting a file with only the description of the

Copyright (C), All Rights Reserved.

processed in 0.168 (s). 11 q(s)