Red Dead Redemption 2 on PC is updated to fix some technical errors
Last week we announced the new section Learn Android in 20 concepts , section oriented introduce the most basic concepts to start our own application program Android .
In fact, besides the 20 concepts , last week we included a point 0 of introduction, where we could settle development environment and have our machine ready to start programming .
Today we speak and the first two concepts: an application Basics and Resources
1. . application
The first thing to mention is that Android applications are written in the programming language object-oriented Java . The Android SDK has a number of tools that will compile the code, including data and resources (which we’ll discuss below), and will get you all in one APK file , or also known as Android package . This file will be our installer
After installing an application, each has its own security system, such that:.
- Each application will be a different user within Android as Operating System based on Linux multiuser system . This user will be a unique Linux user ID. Android
- give permissions to all files in an application only for the user that identifies this app.
- Each process has its virtua own machine l, so that application execution is completely independent.
- By default, each application runs in its own Linux process , which is managed Operating system-level
With all these rules, Android gets implementing what is known as lower Principle privilege , of giving the right permissions to each application, so that the system as safe as possible.
But this is the default behavior, then we can manage it as we are interested, for example to share data between different applications (a perfect example is the Contacts).
Once known as Android works, it’s time to move on to define the components of an application . These are the building blocks that we can build. There are 4 different types of components:
- Activity : Represents a separate screen with a user interface . Although our application will have multiple screens interconnected, we are to generate them individually and independently (can pass data between them, if necessary). Get into more detail in this class when we get to the concept 3
- Service . It is a component that runs down to take lengthy operations or work in remote processes . Contrary to the activity, no GUI. We will see more details on reaching the 11 concept
- Content Provider. This component allows us manage a set of application data sharing . Contacts are the perfect example for this component: we can share data between different applications. But we can create our own set of data (more detail on the concept 13)
- Broadcast Receiver . The fourth component allows us to respond to ads broadcast system . A good example is if we manage when we get the low battery warning (which will send a message broadcast ), though we can design our own posts (more details on the concept 8).
An interesting design aspect of Android is that one application could open to a component of an application B. The perfect example is when we want to use the camera in our app, we can make an Activity with the camera, or open component of the camera which is installed by default in the operating system.
We use a message called Intent , which also serves to activate 3 of the four components of an app (all except the Content Provider), will be seen later there are specific methods to open any component through an Intent (concept 7).
But how do you know our application which components are available? To do this, the file exists AndroidManifest.xml . This file will be responsible to inform the operating system:
- components available to the application
- permissions necessary for the application (camera, GPS …)
- the minimum required version of Android
- the hardware and software required and / or used
- using external libraries (like Google Maps …)
To do this, use tags, which in the case of the components will be:
When do a good program if you have to outsource resources the , meaning resources images, texts, styles … In this way, we can also specify different resources depending on the type of device in which we are, without modifying the code . For this, the perfect example is the mobile version of the same tablet and screen (or Activity to go jargon entering ): create a single Activity which use a different distribution of their content according to the type of device we use.
can always specify a generic resource or default. In contrast to this, we will have the option specify that a particular version of a resource is for a specific configuration .To detail the specific configuration we can build on languages , resolution, device orientation … It is enough to see the possibilities in this here . Basically lies add terminations to the folders where we will store resources commensurate to the specific configuration . All the resources will go under the / res folder. But what are the resources that can include? The :
- Images ( Drawable )
- Layouts (Order of graphic elements)
- Text Strings ( String )
- Other (Boolean, dimensions …)
They must go to a specific folder structure , so that for example to add strings in Spanish would use the folder / res / values-en or / res / drawable-xxhdpi for drawables for high-resolution displays.
Here you can see a flowchart of how Android choose the remedy right:
Being clear how resources are managed, How do we create some specific resources? Let’s look at some of them. Layouts, menus and styles
A layout define the visual structure of a user interface. Although we could dynamically create it by code, ideally declare interface elements in XML .To create a layout, we have many graphical components and the API, although we can create our own. We insert layouts where multiple components, text views, buttons … Here you can see an example of a layout that will put us a text and a button just below:
In this case, a LinearLayout elements will put us one after the other (in this case when its vertical orientation, one below another ). Below is a TextView that occupies the width and height you need (wrap_content) , with text Hello, I am a TextView . And similarly for the button. Each with its unique identifier.If we want to get good at making layouts, ideally start working with the graphic editor eclipse or Android Studio , but go is checking how the XML. As time passes, you will realize that sometimes be faster write directly in XML. When we define menu in one of our activities, it is also defined through an XML. For more information, I recommend visiting the link . Here you have an example:
Finally, when we talk target=”_blank”> styles , we are referring a the closest thing to what CSS is for a web concept outsource styles to be reused. We can define styles to assign to graphic entities and create a topic to assign the entire application
Here you can see how display text in a specific format.
And as remains after use with styles, where CodeFont style could reuse in other Views, or if we decided to change it, could change all at once:
Arrived this point, I think it is time to mention to the guide interface design for Android , a website where we can see trends and tips on how to ride a good user interface.
Finally, to play around with the allocation resource for different configurations, it would be nice should follow this example of Google .
With this we terminate the first two concepts in this section. It is true that these two concepts are very dense, they are concepts which pretend to explain the structure of the application , but many of the things that are named will analyze a posteriori.
Ready for the following items?
February 23, 2014
- ← Show who is connected to your WiFi network with Fing for Android
- TalkBand B1 Huawei smart bracelet that also makes calls →
Next Random post