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

Mobile and Ubiquitous Computing
Labsheet 1 – Getting Started with Android Studio
1. Getting started with Android Development
Welcome to the first lab of the Mobile and Ubiquitous Computing module! Over the coming semester, these labs will give you the opportunity to learn about different aspects of the app development process using Android.
In this lab, you will:
1. Familiarise yourself with the development environment for Android, Android Studio.
2. Create an application from an in-built template.
3. Run the app using the build in Android Studio’s emulator or on your Android device.
2. The Development Environment
In these labs, we’ll be using Java to develop our Android applications. However, Android devices don’t run .class or .jar files like the normal Java Runtime Environment (JRE). This means we can’t just use a typical Java Development Kit of the kind you might have used previously in your studies. Instead we must use the Android SDK. Compiling against the SDK gives us bytecode that can be executed in the Android Runtime.
Although it is technically possible to compile Android applications from the terminal, Android Studio is the easiest way to create applications for the Android SDK. It has a variety of useful features, including GUI-based tools for interface design and good integration with Android emulation. It’s a little bloated and can be very slow but it is the best tool we have.
3. Before you get started

4. Starting Android Studio and creating a new project
First, create a new project (“Start a new Android Studio project”)
Choose to create an “Empty Activity”. Configure this with a suitable name (e.g., AndroidLab1), and ensure that you save it somewhere you can find it later. For the Language, choose Java and for the minimum API Level, choose API 24, Android 7.0, Nougat (we’ll cover API levels in future weeks). Click Finish and wait while Android Studio assembles your project. This might take several minutes!
5. Setting up and running your app
We’ve now created the most basic Android application that we can. It’s made from templates that ship with Android Studio, so we’ve not had to write any code ourselves yet. Let’s if it runs.
Have an Android device of your own?
If you have an Android device of your own, then running you code on it will be much quicker than using an emulator. I recommend this approach if you have a device handy. You will need to enable USB debugging on your device and then plug it into your machine.

Once you have done this, plugged in your device (and made sure the USB setting is it is not set to ‘charge only’), the device should appear in the Android Studio toolbar.
Your device should appear here.
No Android device of your own?
No Android device of your own? No worries, you can use an emulator instead. To do this, let’s create an Android Virtual Device. To do so, click the icon in the toolbar.
Click “+ Create Virtual Device” in the screen that appears. You will be presented with a list of different devices for which ready-built emulation devices exist. I recommend choosing the “Pixel 2” device. Select it and click “Next”

Next you will see a big list of system images. These reflect different versions of Android that can be run on the device that you have selected. I recommend choosing Android Q, which is API Version 29, but just make sure you choose something with API version 24 or higher. You will need to click the “Download” link next to the Android version name. Once that has completed, you can select the image and click “Next”.
The final screen lets you make adjustments to the way that the emulator works. The defaults are fine, so just click “Finish”. You should now see your new emulator in the Android Virtual Device Manager window. You need to start the emulator to be able to use it.
Click to start the emulator
This starts the emulator. This will take a little while, especially first time around. Take a few minutes to stretch your legs and rest your eyes.
Once it has finished booting, you should be able to see the emulator appear in the toolbar as an online device:
Emulator appears here.

Running the app
Now we can run our application on the physical device you have plugged in or in the emulator we have just set-up. Click Run → Run ‘app’ command. Android Studio will go through a few built
stages. This will take a little while too. Eventually, the app will start running on the device you have selected and you’ll see an empty screen. This is your “Hello World” app up and running. 🥳
That’s it for this week. We’re up and running with Android Studio.

Leave a Reply

Your email address will not be published. Required fields are marked *