0

I am developing an app as follows: Android APP (As a client)..it will send data to a Server (Java application running on a PC). I implemented this using socket programming and it is working. I have following issues:

  1. When I click the send button on my app the APP UI freezes for ~7 seconds. It is able to ping and connect to server but during this time frame the UI freezes and if I click any other button on the app I get a message app is stuck (but the app comes back ok after ~ 7 seconds). What is the best way to resolve it.

  2. Once data (strings) is received on the PC, I want to show it in the form of List Box UI so that user can select/double click on the specific string and a message box is open showing that that particular string is selected. What is the best way to develop this UI and how can it be invoked directly as soon as server receives the data from Client (android app) and this UI should show up.

Please let me know. All help is appreciated.

4

1 回答 1

0

将所有与网络相关的代码放入单独的线程中,或者(更容易)和AsyncTask. 否则,您会阻止 UI,正如您已经注意到的那样,应用程序实际上会在较新的 Android 版本(ICS 和 JB)上崩溃。

如果你搜索 SO 和互联网,你会发现很多例子。

于 2013-02-12T03:27:43.203 回答