“Why the heck do I HAVE to call super?”

Did you ever wonder;

“Why the heck do I HAVE to call super?!? If this is something required always, why don’t they just do it for me!”

Here’s the answer to that questions;

Basically, super() is something that must be called if you’re overriding something that MUST be called, which can often be rather complicated code. Now, the reason they don’t just do it for you and call it before your function is mostly so that you have control!

To be more specific, you cannot control IF you call super(), however, you can control WHEN! So, let’s say you have some specific code that needs to happen BEFORE super() gets called, you now have the freedom to call super() only after running your code.

So, the short answer to “why do I have to call super()” is; So that you can control when it’s called and do things before, or after super() gets ran.

Source: http://goo.gl/jDrcyP

Android Runtime (ART)

  • Android Runtime (ART) is an application runtime environment used by the Android operating system.
  • ART replaces Dalvik, which is the process virtual machine originally used by Android.
  • Unlike Dalvik, ART introduces the use of ahead-of-time (AOT) compilation by compiling entire applications into native machine code upon their installation.
  • ART improves the overall execution efficiency and reduces power consumption, which results in improved battery autonomy on mobile devices.
  • To maintain backward compatibility, ART uses the same input bytecode as Dalvik, supplied through standard .dex files as part of APK files, while the .odex files are replaced with Executable and Linkable Format (ELF) executables.
  • Once an application is compiled by using ART’s on-device dex2oat utility, it is run solely from the compiled ELF executable; as a result, ART eliminates various application execution overheads associated with Dalvik’s interpretation and trace-based JIT compilation.
  • As a downside, ART requires additional time for the compilation when an application is installed, and applications take up slightly larger amounts of secondary storage (which is usually flash memory) to store the compiled code.
    ART was first included in Android KitKat, but isn’t yet enabled by default.

Ever Wondered what is Dalvik?

  • DVM is built specifically for android, It is built to address the battery life, processing power & it is free.
  • We are using DVM instead of Java Virtual Machine(JVM) because Java, Java tools are free but the JVM is not free, so the android developers from google have made their own virtual machine and made it as free.
  • Every Android application runs in its own process, with its own instance of the Dalvik virtual machine.
  • The Dalvik VM executes files in the Dalvik Executable (.dex) format which is optimised for minimal memory footprint.
  • The VM is register-based, and runs classes compiled by a Java language compiler that have been transformed into the .dex format by the included “dx” tool.
  • Dalvik is a discontinued.
  • The successor of Dalvik is Android Runtime (ART).

Just Take a look and it is easy to understand:-

.java file — given to — java compiler — to generate — .class file.
all .class files — given to — dx tool — to generate single — dex file
dex file — given to — dvm — to generate — final machine code.
final machine code — given to — CPU — to Execute.