Difference b/w Service and IntentService

Service

This is the base class for all services. When you extend this class, it’s important that you create a new thread in which to do all the service’s work, because the service uses your application’s main thread, by default, which could slow the performance of any activity your application is running.

IntentService

This is a subclass of Service that uses a worker thread to handle all start requests, one at a time. This is the best option if you don’t require that your service handle multiple requests simultaneously. All you need to do is implement onHandleIntent(), which receives the intent for each start request so you can do the background work.
IntentService implements onBind() that returns null. This means that the IntentService can not be bound by default.

Read More »

Services

A Service is an application component that can perform long-running operations in the background and does not provide a user interface.
Another application component can start a service and it will continue to run in the background even if the user switches to another application. Additionally, a component can bind to a service to interact with it and even perform interprocess communication (IPC). For example, a service can handle network transactions, play music, perform file I/O, or interact with a content provider, all from the background.

Read More »

Define AAPT

aapt stands for Android Asset Packaging Tool. This tool is part of the SDK (and build system) and allows you to view, create, and update Zip-compatible archives (zip, jar, apk). It can also compile resources into binary assets.

Define ART, AOT, Dalvik and JIT

Computer (or CPU to be accurate) can understand only machine language (binary codes). So to make it run on CPU, the code must be converted to machine code, which is done by a translator.

The first gen translators were Assemblers, who directly translate assembly codes to machine codes. Since the translation was direct without any intermediate steps, it was fast. The next gen was compilers, which translates the code into assembly codes and then use assemblers to translate the code into binary. The compilation was slower than assembly translation for obvious reasons, but the execution of the program were almost as fast as assembly code. C and C++ compilers are from this generation. The problem with this approach was the code was not cross platform, means the code which runs on one machine, may or may not run on other machine.

Then the next gen was interpreters, which translates the code while executing it. Which means it reads a line, converts into a binary command and executes it and then go to the next line. Since the translation happens at runtime, the execution was slow.

Read More »

Different Android Version & features

Android P (Pie) V9.0  (API level 28) :

1. Indoor positioning with Wi-Fi RTT
2. Multi-camera support and camera updates
3. Privacy changes:
– Build serial number deprecation
In Android 9, Build.SERIAL is always set to "UNKNOWN" to protect users’ privacy.
If your app needs to access a device’s hardware serial number, you should instead request the READ_PHONE_STATEpermission, then call getSerial().Read More »

Gradle

Gradle provides a domain specific language, or DSL, for describing builds. This build language is available in Groovy and Kotlin.

A Groovy build script can contain any Groovy language element.[1 A Kotlin build script can contain any Kotlin language element. Gradle assumes that each build script is encoded using UTF-8.

Read More »

How APK is build?

The Android build system compiles app resources and source code, and packages them into APKs that you can test, deploy, sign, and distribute. Android Studio uses Gradle, an advanced build toolkit, to automate and manage the build process, while allowing you to define flexible custom build configurations.

Gradle and the Android plugin run independent of Android Studio. This means that you can build your Android apps from within Android Studio, the command line on your machine, or on machines where Android Studio is not installed (such as continuous integration servers). If you are not using Android Studio, you can learn how to build and run your app from the command line. The output of the build is the same whether you are building a project from the command line, on a remote machine, or using Android Studio.

Read More »

Difference b/w Abstract class vs Interface

Feature Interface Abstract class
Multiple inheritance class may inherit several interfaces. class may inherit only one abstract class.
Default implementation An interface cannot provide any code, just the signature. An abstract class can provide complete, default code and/or just the details that have to be overridden.
Access Modfiers An interface cannot have access modifiers for the subs, functions, properties etc everything is assumed as public An abstract class can contain access modifiers for the subs, functions, properties
 
Homogeneity If various implementations only share method signatures then it is better to use Interfaces. If various implementations are of the same kind and use common behavior or status then abstract class is better to use.
Speed Requires more time to find the actual method in the corresponding classes. Fast
Adding functionality (Versioning) If we add a new method to an Interface then we have to track down all the implementations of the interface and define an implementation for the new method. If we add a new method to an abstract class then we have the option of providing default implementation and therefore all the existing code might work properly.
Fields and Constants No fields can be defined in interfaces An abstract class can have fields and constants defined

Read More »

Which edition of Java is being used in Android – J2ME or Java SE?

Java platforms:
1. Java SE :  Java SE stands for Java standard edition and is normally for developing desktop applications, forms the core/base API.
2. Java EE : Java EE stands for Java enterprise edition.It is built on top of Java SE, and it is used for developing web applications and large-scale enterprise applications.
3. Java ME Java ME stands for Java micro edition. It is a subset of the Java SE. It provides an API and a small-footprint virtual machine for running Java applications on small devices like cell phones, for example games.
4. Java FX : JavaFX is a platform for creating rich internet applications using a lightweight user-interface API.Read More »