What is
DVM ?
(DVM) is
Register Architecture, designed to run on low memory, uses its own byte code
and runs .Dex file (Dalvik Executable File)
The name
of Android’s virtual machine. The Dalvik VM is an interpreter-only virtual
machine that executes files in the Dalvik Executable (.dex) format, a format
that is optimized for efficient storage and memory-mappable execution. The
virtual machine is register-based, and it can run classes compiled by a Java
language compiler that have been transformed into its native format using the
included “dx” tool. The VM runs on top of Posix-compliant operating systems,
which it relies on for underlying functionality (such as threading and low
level memory management). The Dalvik core class library is intended to provide
a familiar development base for those used to programming with Java Standard
Edition, but it is geared specifically to the needs of a small mobile device.
(JVM) is
Stack Architecture, uses java byte code and runs .class file having JIT.
What
is .apk?
The APK file is compressed the
AndroidManifest.xml file, application code (.dex files), resource files, and
other files. A project is compiled into a single .apk file.
What
are the minimum requirements to run apk?
Manifest.xml,
res, src, bin, project.properties
Project
folder Structure?
What
is context?
It
is a reference to the current object and allows to get the environment details
of application/activity
You can get the context by using any of these
:
- getApplicationContext()
- getContext()
- getBaseContext()
- this
- <ActivityClassName>.this
(When you are in some method of an Interface e.g. onClickListenter)
What
is android market? how to upload android application into android market?
Android
market is Google’s own repository for android apps. Market offers thousands of
applications many of them are free to download
è In Eclipse Goto
File->Export->Export Android Application
è Follow the instructions
è We need to create a keystore with
password; we need to use the exact key every time we need to upload an app
è Goto Googleplay and create an
account
è We have to pay one-time fee of
$25 to upload an app
è Then click the button upload
application, follow the instructions, input the info, click the “save”
è Then” publish”
è Couple of hours later everyone is
able to download that app
Activity
lifeCycle?
What
is the difference between onresume() and onstart()?
onStart() called when
the activity is becoming visible to the user. onResume() called when
the activity will start
interacting with the user. You may want to do different things in this cases,
e.g. in onStart() inflate
layout of activity and in onResume() restore state
of activity.
how
to kill an application in android?
By using system.exit(0)
By
using finish() we can kill only that particular activity
What
is android manifestfile and its advantages?
Gives
info about the all components of android
If we
declare two intent filters with launcher in manifest what happens?
If we
are not providing andorid permission tags or components what happens ?
how
to implement mulitiscreen support and mulitiscreen?
Have
different images for ldpi, mdpi, hdpi and xhdpi
How
to design app for multi screen support?
how
to handle landscape and protrait mode?
When
you rotate a device your activity is restarted. To avoid this, you must handle
the orientation change yourself. To do this, you must add the configuration to
your manifest XML (android:configChanges) and override the onConfigurationChanged function in your activity.
Whenever
device rotated application will be restarted, so on create() will be called
again
In
Manifest file declare either android:onconfigChanged=”orientation”
or
android:screenorientation=”landscape/portrait”
Can a
application be started on booting how ?
yes
how
to call an activity from servicer?
how
to launch an application from another application?
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(newComponentName("com.package.address","com.package.address.MainActivity"));
startActivity(intent);
if
u dnt know the activity name we can use package name
Intent LaunchIntent
= getPackageManager().getLaunchIntentForPackage("com.package.address");
startActivity(LaunchIntent);
Wht
is bitmap how to handle (memory)bitmaps in an application?
what
is advantage of getView in custum listview or custom adapter?
What
is intent? types of intents? give me 2-3 example of each type of intents?
Is
an info that is given to the android system inorder to activate either the
application or one of its components.
1.Implicit:
predefined components
Do
not specify directly the application components which should be called, it only
specifies the action to be performed. An URI is used to specify the data type
*Action->
eg: ACTION_DIAL, ACTION_VIEW, ACTION_CAPTURE
Data-> if there are more than one activity
which have perform same action then go for data; is in the form of URI
Category->
2.Explicit:
used to activate user defined application components
Define
a path of the exact class to be run
How
to design custom views? Example custom linearlayout, button custom imageview
etc?
what
are 9 patch images?
è It is a resizable image that can
be used for backgrounds. The NinePatch class permits drawing a bitmap image in
nine sections.
A
9 patch image is an image that has stretchable areas defined.
These areas are defined in a special 1 pixel wide border around the area. Add black pixels to the top and left of this border to describe where the image can be stretched horizontally and vertically.
These areas are defined in a special 1 pixel wide border around the area. Add black pixels to the top and left of this border to describe where the image can be stretched horizontally and vertically.
Especially
used when designing buttons
What
is intent filter?
It
contains the information about the application components.
These
are required for intent resolution to match intents with activities,
BroadCastReceivers or services.
They
will inform the system which implicit intents they can handle
Activities,
services and BroadCastReceivers can have more than one intent filters.
What
is intent Receiver?
What
is the use of onsaveInstanceState()?
onSaveInstanceState()
is a method used to store data before Pausing the activity
What
is onRestoreInstanceState()?
onRestoreInstanceState()
is method used to retrieve that data back
What
is sticky intent?
How
to apply style and themes in android?
A
style is collection of properties that specifies a look and format for a view.
A style can specify properties like height, padding, font color, margin, size,
background color, border.
If
we want to create a style, save xml file in res->values
Root
node for the style class is <resources>
<style>,
<shape>, <stroke>, <solid>
To set
a theme for all the activities of your application, open the
AndroidManifest.xml file
and edit the<application> tag
to include the android:theme attribute
with the style name.
What is service Types of services?
It
is similar to a thread which runs on background.
Unbound: It is a kind of service which
runs in the background indefinitely, even if the activity which started ends.
Eg: Alarm
Bound: it is a kind of service which
runs till the life span of the activity which started this service.
Eg:
Reminder
OnCreate(),
onStart(), onStop(), onDestroy(), OnBind- callback mehods of services
onStartCommand()- calls when another component
requests that an activity has to be started by calling startservice(); once this method calls the service is started and
runs in background indefinitely. To stop the service we should call stopSelf() or stopService().
OnBind()- calls when another component or activity wants to bind with the service
by calling bindService(). In this method we must provide an interface that
clients use to communicate with the service by returning IBinder. If you don’t want to allow binding then return null.
Oncreate(): calls this method when the
service is first created, to perform one-time setup procedures (before it calls
either OnStartCommand() or OnBind())
OnRebind(): The system calls this method
when new clients have connected to the service, after it had previously been
notified that all had disconnected in its onUnbind(Intent).
-
Once
the service is unbounded from all clients then the system will destroys it.
how
to sent a data from service to activity?
different between thread and service ?
services
are capable of running in the background even when the activity is no longer
available but thread will depends upon the main class.
If
the user runs the thread in the service, the thread will continue to run even
when the user leaves the app also.
|
|
Service
|
Thread
|
AsyncTask
|
|
|
When to use ?
|
Task with no UI, but
shouldn't be too long. Use threads within service for long tasks.
|
- Long task in general.
- For tasks in parallel use Multiple threads (traditional mechanisms) |
- Long task usually with
no communication to main thread.
(Update)- If communication is required, can use main thread handler or broadcast intents - When callbacks are needed (Intent triggered tasks). |
- Long task having to
communicate with main thread.
- For tasks in parallel use multiple instances OR Executor |
|
Trigger
|
Call to method
onStartService() |
Thread start() method
|
Intent
|
Call to method execute()
|
|
Triggered From (thread)
|
Any thread
|
Any Thread
|
Main Thread (Intent is
received on main thread and then worker thread is spawed)
|
Main Thread
|
|
Runs On (thread)
|
Main Thread
|
Its own thread
|
Separate worker thread
|
Worker thread. However,
Main thread methods may be invoked in between to publish progress.
|
|
Limitations /
Drawbacks |
May block main thread
|
- Manual thread
management
- Code may become difficult to read |
- Cannot run tasks in
parallel.
- Multiple intents are queued on the same worker thread. |
- one instance can only
be executed once (hence cannot run in a loop)
- Must be created and executed from the Main thread |
Difference betwen IntentService,
Service?
·
Service class uses the
application's main thread, while IntentService creates a worker thread and uses
that thread to run the service.
·
IntentService creates
a queue that passes one intent at a time to onHandleIntent(). Thus,
implementing a multi-thread should be made by extending Service class directly.
·
Service class needs a
manual stop using stopSelf(). Meanwhile, IntentService automatically stops
itself when there is no intent in queue.
·
IntentService
implements onBind() that returns null. This means that the IntentService cannot
be bound by default.
·
IntentService
implements onStartCommand() that sends Intent to queue and to onHandleIntent().
How
to start a service? and life cycle? how long a service will run in the back
ground?
By
using startService()
Depends
on the code, you can run the background service forever or close it as soon as
the app has been exited. Apart from that, OS itself can close the background
service if no action is performed by it for several minutes.
Example
of remote service?
AIDL:
Android Interface Definition Language
Is
a tool that handles marshaling as well as communication.
It
allows you to define the programming interface that both the client and service
agree upon in order to communicate with each other using inter process
communication (IPC).
What
is widget how to implement widgets?
It
is a piece of program that is also a shortcut to a larger application.
Widgets
are little applications which can be placed on a widget host, typically the
home screen or lock screen of your android device.
Steps to create a Widget
1. Define a layout file
2. Create an XML file
(AppWidgetProviderInfo) which describes the properties of the widget, e.g. size
or the fixed update frequency.
3. Create a Broad castReceiver which
is used to build the user interface of the Widget.
4. Enter
the Widget configuration in the AndroidManifest.xml file.
5. Optional you can specify a
configuration activity which is called once a new instance of
the widget is added to the widget host.
How
to create and apply style in andorid?
explain
about runOnUIThread() ?
What
is onNewIntent()?
onNewIntent()
is meant as entry point for singleTop activities which already run somewhere
else in the stack and therefore can't call onCreate(). From activities
lifecycle point of view it's therefore needed to call onPause() before
onNewIntent(). I suggest you rewrite your activity to not use these listeners
inside of onNewIntent().
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
// getIntent() should always return the most recent
setIntent(intent);
}
service
is already started if again start a same service which method will be called?
how
to avoid ANR(application not responding)?
Different
kinds of storage methods in android?
-
Shared
preferences
-
Content
providers
-
SQ
Lite
-
File
saving and Loading
Data
Sharing methods in android
-
Content
providers
-
Intents
-
TCP/IP
connections
-
Remote
services
-
Writing
to data to SD card
-
SQLite
DB
What
is logcat ? explain about log.v,log.e,log.w etc?
It
is a mechanism for collecting and viewing system debug output.
Log.d:
(Debug)
Log.e:
(Error)
Log.w:
(Warning)
Log.i:
(Info)
Log.v:
(Verbose)
How
to store data into SDCard? answer : extranal, internal, network sqlite,
sharedprefrences
Memory
Management in android?
What
is pendingIntent?
Difference
b/w thread and handler?
Thread
is the process executing the set of statements, by using this we cannot update
the UI
Handlers
are background threads that allow you to communicate with the UI thread.
Handler
allows you to send and process Message and Runnable objects associated with a
thread’s MessageQueue. Each handler is associate with single thread and
thread’s message queue.
There are two main uses for a Handler: (1) to
schedule messages and runnables to be executed as some point in the future; and
(2) to enqueue an action to be performed on a different thread than your own.
Several
ways to access UI Thread from user threads
1. Activity.runOnUiThread(Runnable)
2. View.post(Runnable)
3. View.postDelayed(Runnable,long)
4. Handler
Using
these methods are difficult when we are handling with complex operations. To
remedy this problem android 1.5 offers new utility class “AsyncTask”
What
is AsynTask explain about it?
Running
tasks in background and foreground at a time
Running
the task in the background and updating the UI
Allows
you to perform asynchronous work on your UI
It
performs blocking operations on worker thread and publishes results on the UI
thread, without requiring you to handle thread.
How
to decliar a Broadcaste and what are the advantages and disadvantages of
Broadcaste?
Broadcast
receiver allows you to register for system or application events. It is used to
handle external interrupts
how
to create CustomBroadcaste?explain?
if
more than two broadcaste are decleard then which will be called first?
what
is StickyBroadCaste?
A
Sticky Broadcast is a Broadcast that stays around following the moment it is
announced to the system. Most Broadcasts are sent, processed within the system
and become quickly inaccessible. However, Sticky Broadcasts announce
information that remains accessible beyond the point at which they are
processed.
-
Android
system uses broadcasts to convey information to applications
How
to send an update to installed users about new app update?
What
is parsing? what are the different types of parsings?
Parsing
provides a complete backend solution for your mobile application
1. XML- DOM,SAX
2. JSON
difference
between json and xml parsings?
Xml
is the markup language where as JSON is the way of representing objects.
XML
is a lot easier to read and JSON has a smaller footprint.
XML:
Adv’s: Easier to read
Use
a lot more than json
One
of the main industry standards
DisAdv’s: Takes up more space, increased
bandwidth because of size
JSON:
Adv’s: Dosen’t take up a lot of space,
uses less bandwidth because of its size (footprint)
Raising
in the ranks as one of the main standards in industry
DisAdv’s: Harder to read
For data-oriented applications, I prefer JSON
to XML due to its simplicity and ease of processing on the client side. XML may
be great on the server side, but JSON is definitely easier to deal with on the
client side.
And
the small footprint will speed up transactions between your app and the web
services you're trying to send/receive data to/from.
difference
between sax and dom paring?
SAX Parser:
A SAX (Simple API
for XML) parser does not create any internal
structure. Instead, it takes the occurrences of components of an input document as events, and tells the client what it reads as it
reads through the input document.
A SAX parser serves the client application
always only with pieces of the document at any given time.
A SAX parser, however, is much more space
efficient in case of a big input document (because it creates no internal
structure). What’s more, it runs faster and is easier to learn than DOM parser
because its API is really simple. But from the functionality point of view, it
provides a fewer functions, which means that the users themselves have to take
care of more, such as creating their own data structures.
DOM Parser:
A DOM (Document Object Model) parser creates a
tree structure in memory from an input document and then waits for requests
from client.
A DOM parser always serves the client
application with the entire document no matter how much is actually needed by
the client.
A DOM parser is rich in functionality. It
creates a DOM tree in memory and allows you to access any part of the document
repeatedly and allows you to modify the DOM tree. But it is space inefficient
when the document is huge, and it takes a little bit longer to learn how to
work with it.
what
are handlers and messages?
onHandlemessge,send
empty message, sendmessage,
how
to check whether network connecton is there or not?
explain
about Http and Default Http client?
Sqlite
Database , how to store and retrive data ? how to store image into sqlite
To
store images in databse
Sqlite
openHelper class, Sqlite database, and sqlite statement?
It
is used to manage database creation and upgrading/version management.
It
provides utilities to simplify the creation and initializing the database if it
is not already created.
And
helps in converting the contents of database when your app is upgrading and
database schema changes.
What
is cursor adapter, base adapter, array adapter?
Data
binding using adapters?
What
is a resource?
Layout
resource?
What
is lazy loading?
What
exactly is lazy loading? Though i have used it in one of my app as far as i got
to understand is that data is loaded into cache files which makes it more
faster for the app to load data from url whenever app refreshes.
What
is C2DM? What is recently called as C2DM?
GCM (Goolge Cloud Messaging)?
Is
the process used to send some data from server to the android powered devices
and to retrieve the messages from the devices in the same connection.
Streamline setup makes it simple and easier to
set up the GCM support to android App.
Send-to-sync: (Collapsible)
it tells the
mobile application to sync the data from the server.
Unlike
send-to-sync a message with payload will be delivered. The payload message
contains up to 4kb.
Upstream messaging
over XMPP:
GCM’s
cloud connection service (CCS) lets you communicate with the android devices
over XAMPP connection. ADV: Speed
We
can use HTTP request mechanism also to send messages to GCM servers.
Multi device
messaging: it
maps a single user to a notification key, that makes the user to send one
message to multiple devices.
Push
notifications to GCM server http://www.tejaprakash.com/2013/05/push-messages-to-gcm-server-using-net.html
How
to implement and advantages of C2DM?
An
xml file that describes the layout of an Activity Screen.
-Content
Resolver is used to access the data provided by the content provider
What is a Theme?
A set of properties (text size, background color, and so on) bundled together to define various default display settings. Android provides a few standard themes, listed in R.style (starting with “Theme_”).
A set of properties (text size, background color, and so on) bundled together to define various default display settings. Android provides a few standard themes, listed in R.style (starting with “Theme_”).
What
is an URIs?
Android uses URI strings both for requesting data (e.g., a list of contacts) and for requesting actions (e.g., opening a Web page in a browser). Both are valid URI strings, but have different values. All requests for data must start with the string “content://”. Action strings are valid URIs that can be handled appropriately by applications on the device; for example, a URI starting with “http://” will be handled by the browser.
Android uses URI strings both for requesting data (e.g., a list of contacts) and for requesting actions (e.g., opening a Web page in a browser). Both are valid URI strings, but have different values. All requests for data must start with the string “content://”. Action strings are valid URIs that can be handled appropriately by applications on the device; for example, a URI starting with “http://” will be handled by the browser.
What is an DDMS
Dalvik Debug Monitor Service, a GUI debugging application shipped with the SDK. It provides screen capture, log dump, and process examination capabilities.
Dalvik Debug Monitor Service, a GUI debugging application shipped with the SDK. It provides screen capture, log dump, and process examination capabilities.
Elements in DDMS:
Devices: In the top left corner we can see a tab
“Devices”. There we can get the list of devices and emulator which are on line
(for more understanding see the below picture). Below each instance of the
Emulator or device, we have all processes that are running in this instance.
From left
to right we will see some icons:
I) Bug:
This shows you the debugger state. If it is green that means we are connected
to the debugger and if it is red we are disconnected from the debugger.
II)
Multiple–rows icon: It is an “Update thread” button if we will click on this we
will get the information about running thread in the “Thread” tab.
III) Stop
icon: To stop the selected process.
IV) Screen
Capture icon: By clicking on this we will get a picture of our device/emulator
screen.
Threads: We can view the thread information for
the selected process. To check thread information, go to Devices tab; select
the process that you want to examine the threads for. Click the Update Threads
button. And you will get thread information in Thread tab.
Heap: this will allows you to view how much
heap memory a process is using. This information is useful in tracking heap
usage at a certain point of time during the execution of your application.
Go
to Devices tab; Click on the update heap -> Click on the Cause GC
What is
Drawable?
A compiled visual resource that can be used as a background, title, or other part of the screen. It is compiled into an android.graphics.drawable subclass.
A compiled visual resource that can be used as a background, title, or other part of the screen. It is compiled into an android.graphics.drawable subclass.
What is .apk
extension?
The extension for an Android package file, which typically contains all of the files related to a single Android application. The file itself is a compressed collection of an AndroidManifest.xml file, application code (.dex files), resource files, and other files. A project is compiled into a single .apk file.
The extension for an Android package file, which typically contains all of the files related to a single Android application. The file itself is a compressed collection of an AndroidManifest.xml file, application code (.dex files), resource files, and other files. A project is compiled into a single .apk file.
What is .dex
extension
Android programs are compiled into .dex (Dalvik Executable) files, which are in turn zipped into a single .apk file on the device. .dex files can be created by automatically translating compiled applications written in the Java programming language
Android programs are compiled into .dex (Dalvik Executable) files, which are in turn zipped into a single .apk file on the device. .dex files can be created by automatically translating compiled applications written in the Java programming language
How do I pass data between Activities/Services within a single
application?
It depends on the type of data that you
want to share:
Primitive
Data Types To share primitive data between
Activities/Services in an application, use Intent.putExtras(). For passing
primitive data that needs to persist use the Preferences storage mechanism.
Non-Persistent
Objects For sharing complex non-persistent
user-defined objects for short duration, the following approaches are
recommended:
The
android.app.Application class
The android.app.Application is a base
class for those who need to maintain global application state. It can be
accessed via getApplication() from any Activity or Service. It has a couple of
life-cycle methods and will be instantiated by Android automatically if your
register it in AndroidManifest.xml.
A
public static field/method
An alternate way to make data accessible
across Activities/Services is to use public static fields and/or methods. You
can access these static fields from any other class in your application. To
share an object, the activity which creates your object sets a static field to
point to this object and any other activity that wants to use this object just
accesses this static field.
A
HashMap of WeakReferences to Objects
You can also use a HashMap of
WeakReferences to Objects with Long keys. When an activity wants to pass an
object to another activity, it simply puts the object in the map and sends the
key (which is a unique Long based on a counter or time stamp) to the recipient
activity via intent extras. The recipient activity retrieves the object using
this key.
A
Singleton class
There are advantages to using a static
Singleton, such as you can refer to them without casting getApplication() to an
application-specific class, or going to the trouble of hanging an interface on
all your Application subclasses so that your various modules can refer to that
interface instead.
But, the life cycle of a static is not
well under your control; so to abide by the life-cycle model, the application
class should initiate and tear down these static objects in the onCreate() and
onTerminate() methods of the Application Class
Persistent
Objects Even while an application appears to
continue running, the system may choose to kill its process and restart it
later. If you have data that you need to persist from one activity invocation
to the next, you need to represent that data as state that gets saved by an
activity when it is informed that it might go away.
JSON:
Java Script Object Notation- is a data exchange format which is very condence
-
Based on key/value pairs
-
Key-> string value->num, str, Boolean or an obj
No comments:
Post a Comment