30 Android Interview Questions
1. What are the key components of Android
Architecture?
Android
Architecture consists of 4 key components:
-
Linux Kernel
-
Libraries
-
Android Framework
-
Android Applications
2. What are the advantages of having an emulator
within the Android
environment?
-
The emulator allows the developers to work around an interface which acts as if
it
were
an actual mobile device.
-
They can write, test and debug the code.
-
They are safe for testing the code in early design phase
3. Tell us something about activityCreator?
-
An activityCreator is the initial step for creation of a new Android project. -
It consists
of a shell script that is used to create new file system structure required for writing
codes in Android IDE.
4. What do you know about Intents?
-
Notification messages to the user from an Android enabled device can be
displayed
using
Intents. The users can respond to intents. - There are two types of Intents -
Explicit
Intent, Implicit Intent.
5. What is an Explicit Intent?
-
Explicit intent specifies the particular activity that should respond to the
intent. -
They
are used for application internal messages.
6. What is an Implicit Intent?
-
In case of Implicit Intent, an intent is just declared.
-
It is for the platform to find an activity that can respond to it.
-
Since the target component is not declared, it is used for activating
components of other
applications.
7. What do intent filters do?
-
There can be more than one intents, depending on the services and activities
that are
going
to use them.
-
Each component needs to tell which intents they want to respond to.
-
Intent filters filter out the intents that these components are willing to
respond to.
8. Where are lay out details placed? Why?
-
Layout details are placed in XML files - XML-based layouts provide a consistent
and
standard
means of setting GUI definition format.
9. What do containers hold?
-
Containers hold objects and widgets in a specified arrangement. - They can also
hold
labels,
fields, buttons, or child containers. .
10. What is Orientation?
-
Orientation decides if the LinearLayout should be presented in row wise or
column
wise
fashion.
-
The values are set using setOrientation()
-
The values can be HORIZONTAL or VERTICAL
11. What is it important to set permissions in app
development?
-
Certain restrictions to protect data and code can be set using permissions. -
In absence
of these permissions, codes could get compromised causing defects in functionality.
12. What is AIDL?
-
AIDL is the abbreviation for Android Interface Definition Language.
-
It handles the interface requirements between a client and a service to
communicate
at
the same level through interprocess communication.
-
The process involves breaking down objects into primitives that are Android
understandable.
13. What data types are supported by AIDL?
AIDL
supports following data types:
-string
-List
-Map
-charSequence
and
-all
native Java data types like int,long, char and Boolean
14. Tell us something about nine-patch image.
-
The Nine-patch in the image name refers to the way the image can be resized: 4
corners
that are unscaled, 4 edges that are scaled in 1 axis, and the middle one that
can
be scaled into both axes. - A Nine-patch image allows resizing that can be used
as
background
or other image size requirements for the target device.
15. Which dialog boxes are supported by android?
Android
supports 4 dialog boxes:
a.)
AlertDialog: Alert dialog box supports 0 to 3 buttons and a list of selectable
elements
which includes check boxes and radio buttons.
b.)
ProgressDialog: This dialog box is an extension of AlertDialog and supports
adding
buttons. It displays a progress wheel or bar.
c.)
DatePickerDialog: The user can select the date using this dialog box.
d.)
TimePickerDialog: The user can select the time using this dialog box.
16. What is Dalvik Virtual Machine?
-It
is Android's virtual machine. - It is an interpreter-only virtual machine which executes
files in Dalvik Executable (.dex) format. This format is optimized for
efficient storage
and memory-mappable execution.
17. When does onResume() method called?
onResume()
method is an activity lifecycle method. This is called when the activity come
to foreground. You can override this method in your activity to execute code when
activity is started, restarted or comes to foreground.
18. How to launch an activity in your application?
For
launching an activity, we need to create an explicit intent that defines the
activity
that
we wish to start. In the below code snippet, the first parameter to Intent
constructor
is the current activity context and the second parameter is your new
activity
class.startActivity() method can be called on Activity context.
Intent
intent = new Intent(this, SecondActivity.class);
startActivity(intent);
If
you want to start an activity from fragment
Intent
intent = new Intent(getActivity(), SecondActivity.class);
getActivity().startActivity(intent);
19. How to define an Activity as launcher activity in
application Manifest
file?
All
the activities used in the application should be defined in application
manifest file.
For
launcher activity you need to define intent filter as shown in the below code
snippets.
<activity android:name=".MyActivity"android:label="@string/app_name"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity>
20. What is a ANR ?
ANR
is short for Application Not Responding. Android systems shows this dialog, if application
is performing too much of task on main thread and been unresponsive for a
long period of time.
21. What are the measures to avoid application ANR?
ANR
in application is annoying to user. It can be caused due to various reasons.
Below
are some of the tips to avoid ANR
Perform
all you long running network or database operation in separate thread
If
you have too much of background tasks, then take it off the UI thread. You may
use IntentService
Server
not responding for longer period can be guilt for ANR. To avoid always define
HTTP
time out for your all your webs service calls.
Be
watchful of infinite loops during your complex calculations
22. What is the difference between a regular .png and
a nine-patch image?
The
nine patch images are extension with .9.png. Nine-patch image allows resizing that
can be used as background or other image size requirements for the target
device. The
Nine-patch refers to the way you can resize the image: 4 corners that are unscaled,
4 edges that are scaled in 1 axis, and the middle one that can be scaled into both
axes.
23. How to share text using android share Intent ?
Share
intent is an easy and convenient way of sharing content of your application
with
other
apps.
Intent
sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT,
"This is my text to send.");
sendIntent.setType("text/plain");
startActivity(sendIntent);
24. What is the use of WebView in android?
A
WebView is an android UI component that displays webpages. It can either
display
a
remote webpage or can also load static HTML data. This encompasses the
functionality
of a browser that can be integrated to application. WebView uses the
WebKit
rendering engine to display web pages and includes methods to navigate
forward
and backward through a history, zoom in and out, etc.
25. Define different kind of context in android
Context
defines the current state of application or object. Context provides access to
things
such as creating new activity instance, access databases, start a service, etc.
You
can get the context by invoking getApplicationContext(), getContext(),
getBaseContext()
or this when in the activity class.
//Creating ui instance ImageButton button = new ImageButton(getContext());//creating adapter ListAdapter adapter = newSimpleCursorAdapter(getApplicationContext(), ...);//querying content provider getApplicationContext().getContentResolver().query(uri,...);//start activity. Here this means activity context Intent intent = new Intent(this,SecondActivity.class);
26. What are the different storage methods in android
Android
offers several different options for data persistence.
Shared
Preferences – Store private primitive data in key-value pairs. This sometimes
gets
limited as it offers only key value pairs. You cannot save your own java types.
Internal
Storage – Store private data on the device memory
External
Storage – Store public data on the shared external storage
SQLite
Databases – Store structured data in a private database. You can define many
number
of tables and can store data like other RDBMS.
27. User interface types?
Views
Notifications
28. Types of notification in android?
Tost
notification
Status
bar notification
Dialog
notification
29. How do you find any view element into your
program?
Findviewbyid
30. What is handler class do in android?
Handler
allows yo to send and process message and runnable objects associated with
a thread’s message
queue.
30 Android Interview Questions
Reviewed by Saurabh
on
July 11, 2018
Rating:
Reviewed by Saurabh
on
July 11, 2018
Rating:

No comments: