Вы находитесь на странице: 1из 4

Android Technical Questions

1. Draw architecture diagram of android framework.


Ans:-

2. Which kernel(Operating system) is used in android?


Ans:- The Android is using the Linux kernel 3.6 version.

3. In which language android framework is written?


Ans:- Android framework is written in JAVA language while lower layers
of Library and Kernel is written in C and C++

4. What does DVM stand for ?


Ans:- DVM stands for Dalvik Virtual Machine.

5. Why DVM why not JVM?


Ans:- DVM is faster than JVM, and DVM is under free license.
Android team preferred DVM over JVM because of below given reasons.
Though JVM is free it was under GPU license,which is not good for
Android as most of the Android is under Apache license.
JVM was designed by keep desktops in mind. SO it is too heavy for
embedded devices.
DVM takes less memory, runs & loads faster compared to JVM.
Since mobile devices have lot of limitations like low CPU speed and
less memory, it is always better not to use heavy components like
JVM.

6. Which layer does DVM sits?


Ans:- DVM sits on the Library layer.

7. What is the latest version of android? Can you tell me what is the
new concepts added in this version?
Ans:- Latest version of android is Android O.

8. Explain life cycle of activity?


Ans:- The lifecycle of activity is onCreate -> onStart() -> onResume() ->
onPause() -> onStop() -> onDestroy()

(a) onCreate:
The system calls this when creating your activity.
You should initialize the essential components of your activity.
Eg:- setContentView()
Using findViewById(), to programatically interact witht the widgets
in the UI
calling managedQuery
You can call finish()
If you want any thread running in the background to download
DATA, you can do it here. This has to be deleted in onDestroy().
Derived classes must call through to the super class's implementation
of this method. If they do not, an exception will be thrown.

(b) onStart:
Called after onCreate(Bundle) or after onRestart() followed by
onResume().
You can register a BroadCastReceiver in onStart() to monitor
changes that impact your UI, You have to unregister it in onStop().
Derived classes must call through to the super class's implementation
of this method. If they do not, an exception will be thrown.

(c) onResume:
Called after onRestoreInstanceState(Bundle), onRestart() or
onPause().
Begin animations, open exclusive-access devices(such as the
camera).

(d) onPause:
Called as part of the activity lifecycle when an activity is going into
the background.
The counterpart to onResume().
B will not be created until A's onPause() returns.
Save all your persistent data here.
Good place to do things like stop animations to make switching to
the other activity as soon as possible.
Close your camera here if it is opened.
If device goes to sleep or some dialog is displayed, then it will go to
onPause().

(e) onDestroy:
Perform any final cleanup before an activity is destroyed.
Do not count on this method being called as a place for saving data!
This method is usually implemented to free resources like threads
that are associated with an activity.
Derived classes must call through to the super class's implementation
of this method. If they do not, an exception will be thrown.

(f) onStop:
Called when you are no longer visible to the user.
You will next receive either onRestart(), onDestroy().
This method may never be called, in low memory situations.
Derived classes must call through to the super class's implementation
of this method. If they do not, an exception will be thrown.

(g) onRestart:
Called after onStop() when the current activity is being re-displayed
to the user.
It will be followed by onStart() and then onResume().
If you have deactivated any cursor in onStop(), call managedQuery()
again.

9. If I have a broadcast receiver that updates my UI frequently, then


where should I register that broadcast receiver in my activity life cycle
functions?
Ans:- It should be registered in onStart().
OnStart() function is called just before your activity will be made visible
to the user. So any thing that affects UI has to be registered in onStart()
function.

10. Can I save all my databse tables updations in onStop() of activity?


If not explain why and also explain where should I save db tables?
Ans:- No because onStop() may not be called in some situations.
In case of low memory or configuration changes, there is a chance that
android may force-kill your application before reaching onStop().
OnPause() is the only function that will be called without fail before
killing the application, so save all persistent data like DB tables in
onPause() only.
We can't save all database tables in onSaveInstanceState, because that
function will not be called if user presses back button.

11. What is difference between persistent data and transient data, give
one example. Also tell me which activity life cycle function I need to
use to save them?
Ans:- Persistent data is permanent data that we store Eg:- In database
tables, and transient data is logical data that we use in programming logic.
Persistent means permanent and transient is temporary.

Вам также может понравиться