All,
I'm developing an Android application that connects to other hardware on start up via TCP (over WiFi) . I'm pretty happy with the software that handles the connection -- it does a good job of establishing the socket connection as well as handling things when the connection is unexpectedly lost.
Unfortunately, my application currently just displays a blank, empty screen until the connection is established, a开发者_如何学JAVAnd I expect that this sort of thing may produce unwarranted worry on the part of my users.
I can't figure out how to put up a start-up message informing the user that I have a towel and that there's no need to panic. Can anybody point me to a method for accomplishing this? I'll be happy with just about anything that's legible, whether graphical or textual.
Thanks, R.
Whatever you choose, you need to get the startup screen displayed and more importantly start responding to UI events before the TCP connection is made - ie, you shouldn't do the TCP connection attempt on the UI thread, as if it takes longer than expected you may get an application not responding error.
Do the networking in AsyncTask (another thread, so it won't block the UI). Then you can display all kinds of progress indicators in the UI.
You could use a ProgressDialog
. http://developer.android.com/reference/android/app/ProgressDialog.html
精彩评论