An activity is a single entity that has the focus of the user and can be interacted by the user. Activities have 4 states: Active, Running, Paused, and Stopped.
An intent is like a message that holds a set of instructions. They are often used to launch and link activities. Primarily, intents contain action and data. Actions are those that need to be executed, and data is usually the data that the actions operate on. Intents can additionally contain category, type, component, and extras.
There are two kinds of intents:
As a user, prior to Marshmallow (SDK 22-), you are prompted to give permissions on installation. For OS versions that are Marshmallow or newer (SDK 23+), permissions will be requested when it is needed based on the activity.
As a developer, permissions are not set by default. In order to use protected features of the device, you must include the associated permissions using <uses-permission> tags.
In Android, allocating objects is not free. (memory allocation adds up and eventually causes the OS to have to deallocate objects which means everything pauses for some length of time in the order of 10 - 50 millisec.) Of course, that does not mean to go so far towards reducing object allocation that the code becomes readable. However I think the way this is now is plenty readable, so if I were making the call I would avoid the extra objects.
In our app, we created a POJO (plain old Java object) with just getters and setters. This is a best practice that we observe because it will be useful in more complicated projects, as well as in unit testing. As of now, we have something simple like:
public String getPhoneNumber() {
return mPhoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.mPhoneNumber = phoneNumber;
}
In the future, there may be more complicated logic involved in a getter or setter.
To improve the quality of your app, use the logger to log messages to verify that your app is working as you expected. In the future, this allows other developers to understand what's going on in your code for better readability.
Additionally, when you're debugging your own code, you can use an IDE (such as IntelliJ or Eclipse) or even Google Chrome (depending on what you're making) to debug through your project. You can step through you code and find out where things are breaking.
The UIThread is the main thread of execution for your application. This is where most of your application code is run. All of your application components (Activities, Services, ContentProviders, BroadcastReceivers) are created in this thread, and any system calls to those components are performed in this thread.
Unit tests are pieces of code you write that test small modular pieces (units) of your code to ensure they are working properly. They are vital to code maintenance during the development process. It is also often a good idea to write your code in a way to make them unit testable.