{"id":31,"date":"2019-02-23T07:21:50","date_gmt":"2019-02-23T07:21:50","guid":{"rendered":"http:\/\/engprojects.tcnj.edu\/rccar19\/?p=31"},"modified":"2019-02-23T07:45:33","modified_gmt":"2019-02-23T07:45:33","slug":"under-the-hood-android-application","status":"publish","type":"post","link":"https:\/\/engprojects.tcnj.edu\/rccar19\/2019\/02\/23\/under-the-hood-android-application\/","title":{"rendered":"Under the Hood: Android Application"},"content":{"rendered":"\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/ymwCUzS-I2CiZg5rkjREBt4h5XVeCcSNLW1OOkrCztXrwGmBMoHUQWbgc42L_oYWUF8v1nxQf0V0l9IhkZkhdW4o1b_-J9SBf0cUml7ykdL7errd3shPsw7AvS5ZPsfxfz1yGt6Gg-Y\" alt=\"\" width=\"170\" height=\"282\"\/><\/figure><\/div>\n\n\n\n<p style=\"font-size:12px\">To design and develop an Android application the Android Studio integrated development environment (IDE) version 3.0 was used. <\/p>\n\n\n\n<p><em>Manifest and Backend<\/em><\/p>\n\n\n\n<p style=\"font-size:12px\">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 <em>MainActivity. <\/em>The backend of the <em>MainActivity <\/em>is defined within the file <em>MainActivity.java. <\/em><\/p>\n\n\n\n<p style=\"font-size:12px\">The backend to the <em>MainActivity &nbsp;<\/em>reacts once the <em>MainActivity <\/em>is created, once created the backend waits for the Connect Button to be pressed using <em>.setOnClickListener(). <\/em>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 <em>Socket <\/em>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 <em>192.168.4.1 <\/em>and <em>22, <\/em>this is the IP address and available port number of the Raspberry Pi used during development and testing. <\/p>\n\n\n\n<p style=\"font-size:12px\">\tOnce 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 <em>ObjectOutputStream <\/em>object is created. This will allow the user to send information over an available port on the Raspberry Pi. <\/p>\n\n\n\n<p style=\"font-size:12px\"> 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. <\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/IYrWoKMhHBZXqLwAxp5MyEUC0umpqkXnIz3kp8-BxtndV1cvxdQcZKZyvI41yGEvHfNkt6sbioDoAfjS40pgNYEKwJQxLIi-Cw5-tGMZzyOh-9Kq2k81IQ9CAqQHZWn64DFvaY6sUNI\" alt=\"\" width=\"167\" height=\"279\"\/><\/figure><\/div>\n\n\n\n<p><em>Secondary Activity<\/em><\/p>\n\n\n\n<p style=\"font-size:12px\">This <em>SecondaryActivity <\/em>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 <em>onClick motion event <\/em>that will bring the user to a new activity. <br><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/8UKoMu76Wbr3eTfJNMDWc96iwXy5aC7M5EksNmrsrwu1MpEI2a51t_gDYXEa8eGskkv0sBH7osZTnBMxNQZeYSR24swI5b_LPvdzcLVHsv2FnJE7Q4ga6mTPsf5B1i0hAFET_xLEWig\" alt=\"\" width=\"307\" height=\"184\"\/><\/figure><\/div>\n\n\n\n<p><em>Remote&nbsp;Activity<\/em><\/p>\n\n\n\n<p style=\"font-size:12px\">The <em>RemoteActivity <\/em>activity is created after the <em>Remote Control <\/em>Button is pressed. This activity will contain a <em>stream <\/em>WebView and <em>start_stop, f, l, r, b <\/em>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 <em>stream <\/em>Webview and the inner Relative Layout contained all Buttons. <br><br><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &hellip; <a href=\"https:\/\/engprojects.tcnj.edu\/rccar19\/2019\/02\/23\/under-the-hood-android-application\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Under the Hood: Android Application<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":169,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-31","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/engprojects.tcnj.edu\/rccar19\/wp-json\/wp\/v2\/posts\/31","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/engprojects.tcnj.edu\/rccar19\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/engprojects.tcnj.edu\/rccar19\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/engprojects.tcnj.edu\/rccar19\/wp-json\/wp\/v2\/users\/169"}],"replies":[{"embeddable":true,"href":"https:\/\/engprojects.tcnj.edu\/rccar19\/wp-json\/wp\/v2\/comments?post=31"}],"version-history":[{"count":0,"href":"https:\/\/engprojects.tcnj.edu\/rccar19\/wp-json\/wp\/v2\/posts\/31\/revisions"}],"wp:attachment":[{"href":"https:\/\/engprojects.tcnj.edu\/rccar19\/wp-json\/wp\/v2\/media?parent=31"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/engprojects.tcnj.edu\/rccar19\/wp-json\/wp\/v2\/categories?post=31"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/engprojects.tcnj.edu\/rccar19\/wp-json\/wp\/v2\/tags?post=31"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}