Skip to content

Latest commit

 

History

History
55 lines (45 loc) · 1.55 KB

File metadata and controls

55 lines (45 loc) · 1.55 KB

Basic Android Chatting Bot -- Notes

Contents of an Android Project

  • xml file
  • java
  • layout resources

Steps of doing this project

  1. UI Layout

    1. Create layout (LinearLayout, RelativeLayout, GridLayout) and widget (eg: Button, EditText, TextView, ListView, ScrollView)
    2. LinearLayout: (1) Need to specify orientation (vertical or horizontal) (2) layout_weight: "0". How this feature is used to differentiate our words and server words
    3. ListView
    4. TextView and Button
  2. Implement functionalities of those UI widgets

    1. ListView

      • ListViewAdapter
        • Create a new Adapter class extending ListAdapter
        • Override some methods: getItemId, getView, etc.
      • File in internal memory to store messages history
    2. Listener

      • Button: setOnClickListener
      • Edit: addTextChangedListener
    3. File in and out

      • File
      • FileInputStream
      • ObjectInputStream
    4. ClearMessageHistoryButton

      • Delete the file and mMessages ArrayList
    5. SendMessageButton

      • OkHttp include the two jar files
      • Send request and define the callback method
    6. OnResume() Android Activity Lifecycle() basic-lifecycle

    • Start: onCreate() -> onStart() -> onResume()

    • Change configuration: onResume()

    • Pause (suspend / black screen): onPause()

    • When paused: if something unexpected happens (memory runs out, etc) onStop() onDestroyed()

    1. Add Internet Permission