No matter where you go, the majority of people you meet along the way will have their heads down, focused on their smartphones. They will most likely be working remotely, chatting with friends or family, or just enjoying an addicting game. The applications in our phones are so many and diverse that this market is booming right now. So why not take a closer look and dive into the heart of the phenomenon? Focus on mobile application development on Android.
Install the software
Let’s start with the beginning ! Have you decided to launch your first Android application? So the first step is to install Android Studio, because you will need a development environment.
What is a development environment?
This is mainly development environment The software or a set of software, which will allow you to develop applications for a given platform. To make it easier to understand:
- For a Windows program: use Visual studio ;
- For an iOS mobile application: use Xcode ;
- To develop an Android mobile application: use Android Studio.
Obviously, it is the latter that will interest us for this article.
How to download Android Studio?
THE’IDE official supported by Google to develop an application on Android is Android Studio. Then, once on your computer, go to Android Studio software download page. Don’t worry, because the download page will automatically detect your operating system and thus offer you to download a compatible version for:
If you ever want to download a different version, for whatever reason, click on the button. Download Options. This will allow you to select the version you want to download. Also, it is good to know that the download will take some time, as the archive is quite large. Take your troubles patiently or opt for a download with optical fiber available.
At this point, after having followed all the installation steps, you can now configure your environment by clicking on the button Configure. Before starting, you will therefore configure the IDE according to your preferences and tastes. To do this, click on the bottom Configure, then on Preferences. Don’t forget to click on the button Apply at the bottom of the window to apply the changes:
- Theme : to configure the main theme, click on Appearance & Behavior then Appearance and Theme. You will then have the choice between the default theme, clear in appearance and the theme Darcula, with a slightly darker appearance. If you want to make it look more professional, we recommend that you choose the theme Darcula. However, if you want to sound like an 80s developer, so a little more classic, stick with the standard theme;
- Code Style: many have particular preferences in terms of indentation or from placement of braces. If this is your case, click on Editor then Coded Style and Java. Thus, you will be able to change all the rules for indentation, placement, style or even code generation.
- Keyboard shortcuts : like Android Studio is based on IntelliJ IDEA, which is a IDE very intelligent and ergonomic, it is full of keyboard shortcuts. Indeed, these shortcuts can make your job considerably easier. In addition, generation 2.0 is used to doing without the mouse and using only the keyboard. Another good point for your app.
Create your project
Now that the software Android Studio is launched, now click on Create New Project. Then, it is essential to know that an activity or Activity, is here fundamental brick regarding interaction with the user. It is therefore the activity that will contain all the graphic elements like text field, button, title, … In order to facilitate the developer’s task, the creation wizard in Android Studio will then automatically create predefined activities. For example, you have: an activity to display a map Google map or for display in landscape mode on a tablet or smartphone.
Enter the name of the app in the tab Name: this will be the name, by default, which will be visible below the application icon on the user’s phone home screen, but also in the application title bar. Also, if you change your mind over time, or the name no longer fits the content you’ve chosen to embed, you might be able to change it over time.
Choose a name without duplicates
The Android Studio software then allows you to determine which package name you will use for your first application. This will later distinguish your application from another with the same name and the reverse notation is used. Indeed, if you work for the company WorldSociety, you can completely specify: com.worldsociety.android, but remember that you are completely free to specify the name that suits you. However, avoid using a domain name that is not yours to avoid having to deal with a duplicate the day you want publish your application on Google play store.
The minimum SDK version
One of the steps not to be missed when developing an application is to specify the minimum version of SDK to use for your project. Then meet on the spot Minimum SDK. Then, it is advisable to use a recent and high API, as it will allow you to benefit from all latest features offered by Android. However, always keep in mind that old devices still sold on the market and which are not up to date will not be able to operate and therefore launch your application. So, to help you in this direction, click on the link Help me choose. The graph displayed on your screen will allow you, at a glance, to check the percentage of devices that will be able to install and run your application. Therefore, the closer you get to 100%, the better!
Let the software load your app
You are almost there!
- Leave the box Use legacy android.support libraries unchecked;
- Click on the button Finish ;
- A window with a loading bar will appear and warn you that the software is building your application: Building (project name) Gradle project info.
Wait a little longer, while all the files necessary for the proper functioning of your application are downloaded. Then you will see the main screen appear Android Studio.
Explore your project
You will now see a maze of buttons that you can click on the edges of the main window. Do not panic and above all do not rush, because for the moment, the button that interests you is the button 2. This button will allow you to display tree structure files in your project. Each open file will then be displayed in tab 3. You can then have fun clicking on each button on the edges to reveal the content. If you click a button again, the window will be hidden. Do not panic if you no longer see any button on the edges: you just have to click on the square at the bottom left of the window and everything will be restored!
Create the interface of your application
The interface is very important to give a good impression to the users.
Create two activities
The major role of an activity is to interact with the user of your app. In addition, it is a class Java Where Kotlin which necessarily inherits from the Android Activity or AppCompatActivity class. To put it simply, if for example you want to have two screens in your app:
- A login screen;
- A tutorial screen;
You will therefore have two activities:
- A first which manages the connection part;
- A second which manages the display of the tutorial.
Use a layout file
By convention, the name of an activity will always be suffixed by Activity and will be written in Camel Case. Then, to determine which graphic elements to use and especially how to position them on the screen, you should use a layout. The definition of a layout file is as follows: it is a XML file that the activity will load after being instantiated and that is still stored in the directory res / layout of your project.
The graphic editor
By default, the software Android Studio open the editor in mode Design. Therefore, you will be able to place and configure each graphic element with the mouse and automatically generate the content. XML.
In order to be able to display elements on the screen, it is essential to use a container. A container is essentially a particular element that will allow you to organize the elements it contains between them. Here are the types of containers offered by Android:
- FrameLayout : to position the elements one above the other;
- LinearLayout : to position the elements one after the other, horizontally or vertically;
- RelativeLayout : to position the elements relative to each other as well;
- ConstraintLayout : as the RelativeLayout, but with more powerful positioning rules and a little more difficult to handle for beginners.
Manage user actions
Check user input
Make sure that each user of the application has entered their first name before proceeding further. So, to prevent him from going any further, it will be necessary to deactivate the game start button when launching the application and then activate it when he has entered his first name.
Detect the button click
When the button is activated, the user will now be able to click on it to launch the game. To detect that the user has clicked on the button, it is necessary to implement a listener.
Now that you have the basics, you can start launching your first app on an emulator! However, if you are not very comfortable with all the computer gibberish, you may still be able to call in a company specializing in mobile application development.