Hi, I am Michel Ianotto. In this module I will present you how to develop a simple Android application. We will see how to create, compile and run the application using Android Studio IDE. We will see also how to transfer the application on the physical Android device and on an emulator. At the end of this module you will be familiar with some Android tools. As concerns the installation of Android Studio, we just give some links on web pages that explain how to download and how to install Android Studio on your PC. The package can be downloaded from the following web page. The package is available for Windows, Mac and Linux operating system. Once Android Studio is downloaded the exact steps to install android studio on your PC depending on the operating system on which the installation is being performed. Installation instructions for Linux, Windows and Mac operating system platforms can be found from the following web page. You have to know that the installation of Android Studio takes some time. When the installation of Android Studio is finished we can launch Android Studio. And when Android Studio is launched, the following screen appears. First, we have to create a new project by clicking on the button start a new android studio project. In the first window we have to set the field application name. For example we can give the name My First Application to our application. We keep the default values for company domain and for project location. Then, click on Next. The application is developed for phone and tablet. We keep also the default value for this field. The minimum SDK is API 16 then we click on next. Here you have the choice between several activities. Just like a blank activity or empty activity. We can select empty activity for example. And click on Next. In the last window we have to set the Activity Name field and the Layout Name field. We can also keep default values for these two fields and click on Finished. We can close this window. At this point Android Studio has created several files and directories. On the left side on the screen we find three directories. The manifest directory, the Java directory and the res directory. In the Manifest directory the is a file. The name of the file is AndroidManifest file. The file contains the properties of the application. In the module four of the MOOC, we'll see how to modify this file. For the moment we
don't have to modify this file In the Java directory, we find the source files of the application. In this directory we find the main activity file that contains the source code of the application. We'll see how to modify this file. And the third directory is a directory that contains resources of the application. We have the layout subdirectory that contains the graphical resources of the application. By double clicking on the activity_main file, we can display this screen. At the bottom of the screen we have two tabs. The design tab and the text tab. If we select the text tab we can display the content of the activity_main file. And if we come back to the design tab, we also display the screen on the application. It's possible to modify the user interface of the application directly by modifying the activity_main file or Using the designer tools of Android Studio. Now we are going to modify the user interface of the application using designer tools of Android Studio. To do that we use the User components of the palette. First, we have to delete to the text view component which is located at the left corner of the screen. To remove this component we just have to select the component and then press the delete key of the keyword. We select to large next component from the widgets category of the palette. And drag and drop it in the center of the screen. Then we change the text of this component by double clicking on the component and change the text from Large Text to My First Application. At this point, there is a lightbulb that appears at the left side of the component. This light bulb indicates a possible problem with this component. For the moment, we keep this warning, and we will see in the module five of the MOOC how to suppress this warning. At this time the design of the user interface is finished. And we can switch to the XML view of the user interface by double clicking on the text tab which is located at the bottom of the screen and then we can display the content of the XML file. And now we are going to see how to use the android virtual device emulator to test the application. The android virtual device emulator can be used to test the application without installing the application on a physical Android device. For testing the application, we have to create a new Android virtual device. To create this new device, we have to click on the AVD Manager button, which is located at the top of the window. And if we click on this button the following window is displayed. To add a new Android virtual device we click on the button, Create Virtual Device. In the following window we have to choose a device. For example, we can choose Nexus 6 device and click on the button Next. In this window we have to select the version of Android that will be run on the device. There are two versions of Android. The Marshmallow version and KitKat version. Here we choose the Marshmallow version API 23. and click on Next. Here we have to set the field AVD name and we can keep the default value and click on Finish. And the new Android virtual device is created. To launch this new Android virtual device we click on the green triangle, and the new Android virtual device is started. The start of the new AVD may take some time. Once the emulator is launched, the following screen appears. We can come back to the Android Virtual Device Manager and close the window. Now we can run the application by clicking on the green triangle which is located on the top of the window. And we choose the device Nexus 6 and click on ok. And then the application is launched on the emulator. It's also possible to launch the application on a physical device. To transfer and run the application on the physical device you first have to install the appropriate USB driver on your system, on your PC. Instructions to install the appropriate USB driver on your system can be found at the following webpage. Once the driver is installed on your PC the device must be configured to allow the connection from the PC. On phone and Tablet devices running Android 6.0 or newer version of Android, you have to do the following steps. In the Settings app of the device select the about phone option. In the About Phone option find the Build number field and and tap on it seven times until a message appears indicating that the developer mode has been enabled. We can see on this picture the build number field. At this point, the device is configured to accept a debugging connection from Android Studio. Then you have to connect your Android phone to the PC. Once the connection between the PC and the device is ok, you can launch the application on the physical device. The first method is to launch the application from Android Studio by clicking on the green triangle, which is located at the top of the window. If I click on this button the following window is opened. And I can select the emulator or I can select the physical device. I have the choice between the two devices. Here I select the physical device and I click on Ok and the application is launched on the physical device, as we can see on my screen. Another way to launch an application on a physical device is to manually install the APK file on the device. First you have to connect your smartphone to your pc. Then you have to go to the directory that contains android project. This directory is named AndroidStudioProjects. I open This directory. Then I find in this directory all the projects that have been created by Android Studio. I select the project MyFirstApp. I open the directory, then I open the directory app, then the build directory, and then the outputs directory and then apk directory. I select the first file, and I copy it on my smart phone. I copy the file in the Download directory. Before running the apk file you have to tell to your smartphone that it can run and install any the application outside of the Play store. For that you have to double-click on Settings icon of the device and select the Security option. In the Security option, you have to enable the Unknown Sources option. Then we can run the application directly from the smartphone. I use the file manager application. to find the APK file. I select the download directory, I select the APK file. I make an update, ok, install an update. Application is installed. I open the application, and then the application is launched. The application which has been developed in this module is a very basic application. As you can see it is very easy and quick to develop an application on Android Studio. Android Studio is a tool that offers a lot of functionalities. In this module we saw only some functionalities of Android Studio. In the next module of the MOOC, we will see all the possibilities of Android Studio.