To design and develop an Android application the Android Studio integrated development environment (IDE) version 3.0 was used.
Manifest and Backend
The app manifests file tells the Android operating system what activity to run, what activity to display, what backend program to use, and run the main intent. This file tells the Android operating system to run the MainActivity. The backend of the MainActivity is defined within the file MainActivity.java.
The backend to the MainActivity reacts once the MainActivity is created, once created the backend waits for the Connect Button to be pressed using .setOnClickListener(). This function will override once a button click is detected. Once the click event is detected, a Client object is created from the verified IP address and Port number. This Client object then creates a unique Socket object to send encoded information over a user specified port number. If a successful socket is created, the Connect Button color is reset to green to notify the user of a successful connection being made. The parameters by default are set to 192.168.4.1 and 22, this is the IP address and available port number of the Raspberry Pi used during development and testing.
Once a successful connection is made, the user is then able to press the forward arrow ImageButton to send a forward instruction and then any combination of left and right arrow ImageButtons may be pressed. This will toggle the on/off ToggleButton, notifying the user that the autonomous car is in the process of performing a motion. In order to send an encoded forward instruction, an ObjectOutputStream object is created. This will allow the user to send information over an available port on the Raspberry Pi.
The information sent over the port is encoded using the UTF-8 encoding standard. The instructions set by the user are sent as an integer: 1 to indicate right, 2 to indicate left, and 3 to indicate forward (on) or off. This integer is sent along with a one or zero to indicate a stop instruction or go instruction. These bit streams are then sent over the port to be sent to the Raspberry Pi that is listening over the same port.
Secondary Activity
This SecondaryActivity activity is created after a successful connection is made with a Raspberry Pi. This activity serves as a main menu for the user, giving them the following options: remote control, set instructions, previous runs, disconnect, and more. Each of these options are represented within the activity as a Button component. Each Button component is listening for an onClick motion event that will bring the user to a new activity.
Remote Activity
The RemoteActivity activity is created after the Remote Control Button is pressed. This activity will contain a stream WebView and start_stop, f, l, r, b Buttons. To allow for a Button overlay, a layered layout needed to be created. To do this, a Relative Layout was placed within a Relative Layout. The outer Relative Layout contained the stream Webview and the inner Relative Layout contained all Buttons.