This assignment involves building and deploying a simple Hello World app. This exercise involves: • Building an Android app with a user interface (activity). • Accepting user input in the app. • Displaying the user input The Android developer website provides a wealth of information about Android, including instructions for building and running your first Android app: http://developer.android.com/training/basics/firstapp
However, you should avoid using the Android Studio wizard to create activities, since it introduces several complications. Create an empty project (with no activities initially), with package name edu.stevens.cs522.hello, and then add an empty activity. Configure the target platform for the app to be Android API Level 33 (Tiramisu). In the application manifest, the element will specify the theme that styles the application: … The theme itself should be specified in a file res/values/themes.xml: Do not leave the theme as the Google material design theme that the wizard in Android Studio prefers. We will be using that theme later, when we incorporate elements of material design into the app. You will need to create an element as a child of the element in the manifest, and this will need to specify the right action (to make this the activity launched for the app) and category (to make sure it shows on the app launcher): The activity itself displays a layout that includes a prompt, a text box for user input, and a button for signaling when user input is ready. This should be defined as a layout resource in res/layout/activity_main.xml: The prompt string is defined as a string resource in res/values/strings.xml: What is your name? You should also define a name for the app that includes your own name as a string resource, so that it is displayed at the top of the app screen (see the application element above): XYZ’s First App Create a class for the main activity of this app, whose onCreate method inflates this layout on the device screen: public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } } However, this app will not react to user input. You will need to add a callback for button presses (Don’t forget to put a text label on the button in the view). You can make the activity itself be this callback object: public class MainActivity extends Activity implements View.OnClickListener { @Override protected void onCreate(Bundle savedInstanceState) { … button = (Button) findViewById(R.id.button); button.setOnClickListener(this); } @Override public void onClick(View v) { … } } On receiving the button press, the callback should get the input text from the text box, and launch another activity using an explicit intent: Intent intent = new Intent(this, ShowActivity.class); intent.putExtra(ShowActivity.MESSAGE_KEY, text); startActivity(intent); The child activity displays this text on its screen: public class ShowActivity extends Activity { public final static String MESSAGE_KEY = “message”; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_show); String message = getIntent().getStringExtra(MESSAGE_KEY); … } } For the layout for this child activity, make it a linear layout with a single text view, and programmatically set the string to be displayed in the activity. You should run the app on a virtual Android device of your choice (e.g. a Pixel 4), or on your own physical device if you prefer and if it supports the API. You can watch the processing of your application (insert log statements in your code for more information) in the logcat window in Android Studio. Once you have your code working, please follow these instructions for submitting your assignment: 1. Create a zip archive file, named after you, containing a directory with your name. E.g. if your name is Humphrey Bogart, then name the directory Humphrey_Bogart. 2. In that directory you should provide the Android Studio project for your Android app. 3. Also include in the directory a completed rubric where you self-evaluate your submission. 4. In addition, record a short mpeg (MP4) video of a demonstration of your deployment working. Make sure that your name appears in the video. It should appear in the title bar of the app while it is running. Do not provide private information such as your email or cwid in the video. Your solution should be uploaded via the Canvas classroom. Your solution should consist of a zip archive with one folder, identified by your name. Within that folder, you should have one Android project, for the app you have built. You should also provide a completed rubric for your solution, as well as a video showing the app working.
Reviews
There are no reviews yet.