Android Development FAQ (Frequently Asked Questions and answers)

This post lists the Android Apps Development FAQ (Frequently Asked Questions and answers) also a collection of many trouble shooting use cases.

Android is a mobile operating system. It is a Linux-based operating system used in various devices such as mobile, refrigerators, televisions, etc. 

The Google Android SDK is the toolset. It is necessary for the developers to run the application on android enabled devices. It carries a graphical interface that provides an android a similar environment to test and debug the app.

Andy Rubin is the founder of an android.

The different layers in the android heap are considered android architecture. It comprises the operating system, the different application involves, and middlerwares. Each layer provides different services and functions. The four layers are: 

  • Linux Kernal
  • Libraries with android Runtime
  • Application Framework
  • Android Applications

To know more about android architecture, click on the link below:

https://tutorialslink.com/Articles/Introduction-to-Android/1132

The features of android are:

  • Open-source: The user does not need to pay the license, distribution, and development fee.
  • Platform-independent: It supports all the operating systems such as Windows, Mac, and Linux.
  • Supports different elements: It provides support to Bluetooth, camera, wifi, speech, etc.
  • Highly optimized VM: Android uses a highly optimized Dalvik Virtual Machine. 

The build has three steps:

  • In the first step, the compilation of the resource folder will take place using AAPT(Android Asset Packaging Tool). It compiled into a single file known as R.java that carries only constant. 
  • In the second step, the source code of the java file needs to compile using javac which is converted to Dalvik bytecode using the dx tool, and the final output comes in classes.ex.
  • In the third step, the Android apkbuilder is necessary to take all the inputs and build the android packaging key(APK) file.

Android Framework is an important element of android architecture. The developer can find all the required classes and methods needed to write an application. It is the third layer in architecture. 

AAPT stands for Android Asset Packaging Tool. It gives the developer a feature to deal with zip-compatible archives that involve creating, extracting along viewing its content. 

The programming languages used in android:

  • Java: The most popular programming language used in writing the application and the majority of people using the same language worldwide.
  • Kotlin: It is a new, safe, and object-oriented programming language. It is announced as an official programming language of an android.
  • C#: It issued to build native iOS and Android mobile applications.
  • Python: It is the most popular dynamic and object-oriented programming language.

The emulator plays an important role in the life of the mobile application developer. It acts in a way similar to the real device. The developer can write, test, and debug the code. In the initial phase, it is a safe way to test the written code.

The apk stands for the Android application package. It is a compressed file that is used to share and install the application on mobile devices or Google's Android operating system. The file has .apk extension. It has all the application codes, resources, certifications, and all the files compressed in it.

ADB stands for android debug Bridge. It is a command-line debugging application embedded with SDK. It enables developers to communicate with the devices. It makes the actions easy such as installation and debugging of an application. 

It smoothens the communication between client and service. To proceed with the communication between the two processes, the data is split into small portions which are easily recognized by the android platform.

Activity is much similar to frame or window in Java. It represents the graphical user interface. It acts as one screen. It is used to display the output or ask for input. 

The lifecycle of activity:

  • OnCreate(): It is the first method called where activity is created. The views are created in this as well as data is collected from bundles.
  • OnStart(): This method is called when the activity becomes visible to the user. It may be called after OnResume() when the activity becomes foreground and OnStop() if it is hidden.
  • OnResume(): This callback method is called when the activity starts interacting with the user.
  • OnPause(): It is been called when the activity comes into the background but hasn't killed yet.
  • OnStop(): The callback method is called when the activity is no more noticeable to the user.
  • OnDestory(): The method is called to destroy the activity to free up the memory space.
  • OnRestart(): It is called when activity has been stopped and before it starts again. 

The folders along with the description:

  • gen: gen contains the compiled .R generated files that point out all the resources of the project.
  • src: It holds .java source files in our project. 
  • bin: It contains the .apk file built by the android development tool as well as those things also that are not needed to run the android application.
  • AndroidMainfest.xml: It explains all the features of the application and the definition of the components.
  • res/values: It has value files such as color, strings, and the theme file of the project.
  • res/drawable: This directory has drawable and different screen XML files.
  • res/layout: This directory has the layout files of each activity.  

Android Runtime is used to provide the runtime environment. Earlier Dalvik is used but now android runtime is used. Android Runtime tool translates the bytecode of the application into a native instruction, which is carried out in the runtime environment of the device.

It is the element to pass the message or information to other components. It is used for various purposes such as display a web page, launch a new activity, send an SMS, send an email, make a call, etc. 

There are two types of intent:

  • explicit 
  • implicit 

Explicit Intent: This type of intent will take you from one activity to another activity. When you want to launch another activity through intent, then explicit intent is used. 

Example: Intent intent = new Intent(this, anotheractivity.class);

               startActivity(intent);

Implicit Intent: This type of intent is used when you want to send an email, send an SMS, open a web page and more. 

Example: Intent intent = new Intent();

               intent.setAction(Intent.ACTION_VIEW);

               intent.setData(Uri.parse("http://www.google.com//");

               startActivity(intent);

File: It is a block of mixed information and resources for storing information. The file can be of any type.

Class: It is a compiled form of .java file that is used by android to produce the .apk file.

Activity: It is not a file but a class. It is used to extend android to load UI elements in a view. It is a user interface.

Toast is the notification or message that views the user's activity. It fades in and out for a short period of time only. It does not carry any user action. 

Example:

Toast.makeText(this, "Message you want to display", Toast.LENGTH_SHORT/LENGTH_LONG).show();

ANR is the abbreviation of "Application Not Responding". The message is displayed to the user when the main thread in the application is not responding for the longest time. The conditions when this happens are:

  • When the input event is receiving any response even after 5 seconds.
  • When the broadcast receiver is not executing even after 10 seconds.

The following things you can do to avoid the situation:

  • A developer can perform lengthy database and networking operating in individual threads.
  • Create a child thread and put a part of the code that is non-responsive for a long time. Keep that part away from the main thread so that it can respond in a minimum required time.
  • Release the pressure on UI by using the IntentService method.

As the name itself suggests, it contains something inside. The containers are used to hold objects and widgets together completely depends upon the type of item is needed and in which particular order. Containers can hold anything such as buttons, fields, labels and can hold child containers as well. 

activityCreator is the new initial step to create a new android project. It is made by the shell script. It is used to create a new file system structure that is necessary for writing the codes within the Android IDE.