Write an Android terminal to chat with a server.
- How this app works.
- A server is set up on AWS at
http://54.161.23.101. We can visit it via either curl or browser.
Test: Open a console; type incurl http://54.161.23.101/basicRequestto see the server's response. - The app sends out a message, and the server responds.
- More detailedly, when you click on "send", the app (1) Updates the message display area.
(2) Sends out a request containing the message, and the server responds with a random sentence.
(3) After receiving the response, update the message display area again.
(4) How to update the message display area? Update theArrayList<String> mMessagesand callmListAdapter.notidyDataSetChanged()
- A server is set up on AWS at
- Start an Android Studio Project
- Basic Contents on Android side
- Set up layout xml file.
- Talk about RelativeLayout, LinearLayout, and ListView. ListView shall not be placed within ScrollView
- XML attributes and how to reference using
@ - Resources: color, string, dimension, style, drawables
- Wire up EditText widget and the Button widget.
- addTextChangedListener: save the current text to variable;
- onClickListener: Write to file and update ListView.
- Preserve messages in onPause() and recover them in onResume()
- Set up ListView and adapter.
- Set up layout xml file.
- (Optional) Further steps:
- Shoot up a request to server.
- Customizing View.
- What if the network is slow? What if the Activity is unexpectedly closed when the other Thread is running?
- TODO -
- The first line of message shifted to center after the request is responded.
- If there is no response from Internet, set a timeout mechanism (?) in OkHttp?
- Server side: use more intelligent chatting algorithms. Play around with gensim if possible.


