CS计算机代考程序代写 android Java chain Mobile and Ubiquitous Computing

Mobile and Ubiquitous Computing
Labsheet 5 – Intents, Bundles and Threads
In expectation of your assessment in Week 6, this week will be a relatively light week in terms of work on this labsheet. So far, we’ve focused on single activities. You start your application, do something on one activity and then that’s it. (From Labsheet 4, you should now also have a basic idea of how you can lay things out in your applications.) Obviously, real apps tend not to work like this. There are normally main activities chained together to produce complex and useful interactions. This week we’re going to focus on extending our application so that it comprises two activities.
Multiple Activities, Multiple Intents
Recall, an activity is a single focused thing your user can do. If you chain multiple activities together to do something more complex, it’s called a task.
Here you’re going to build an app that contains two activities:
1. Typing a message
2. Displaying the message that was typed
Let’s get started:
The mains steps to get going will be:
1. Create a basic app with a single activity and layout
2. Add a second activity and layout
3. Get the first activity to call the second activity
4. Get the first activity to pass data to the second activity
The Structure of the App:
The app contains two activities and two layouts:
1. When launching the app, CreateMessageActivity is started
This uses the layout activity_create_message.xml
2. The user clicks on a button in CreateMessageActivity
This launches activity ReceiveMessageActivity, which uses layout
activity_receive_message.xml
First things first:

Create a new ‘Add No Activity’ project an application named “Messenger”. You’ll need to create a blank activity called “CreateMessageActivity” with a layout called “activity_create_message”. To do this click File → New → Activity → Empty Activity. Set the activity name to CreateMessageActivity and the layout name to activity_create_message. Tick ‘Launcher Activity’ for this activity and then click Finish. You should now have an activity ready to use as normal.
In activity_create_message.xml in res → layout in the project tree, remove (using the Design view), add a Button and an EditText element. An EditText element gives you an editable text field you can use to enter data.
As in last week, update strings.xml to hold the relevant value for the text of the send button (“Send Message”), and create the method onSendMessage() in CreateMessageActivity.java, that will fire
when the button is pressed. Remember, this will take a View object argument. (Think back, or look back, to last week if you’re stuck.) You should end up with something that looks a little like this in
your layout XML: