Using with findViewById we can find view element.
What are application Widgets in android?
App Widgets are miniature application views that can embedded in other
applications (such as the Home screen) and receive periodic updates.
These views has referred to as Widgets in the user interface, and you
can publish one with an App Widget provider.
How to update UI from a service in android?
Use a dynamic broadcast receiver in the activity, and send a broadcast
from the service. Once the dynamic receiver is triggered update UI from
that receiver.
What is sleep mode in android?
Sleep mode mean CPU will be sleeping and it doesn't accept any commands
from android device except Radio interface layer and alarm.
What is singleton class in android?
A class which can create only an object, that object can be share able to all other classes.
What are the different storages available in android?
- Shared Preferences
- Internal Storage
- External Storage
- SQLite Databases and
- Network Connection
What is nine-patch images tool in android?
We can change bitmap images in nine sections as four corners,four edges and an axis
What are the notifications available in android?
Toast Notification − It will show a pop up message on the surface of the window
Status Bar Notification − It will show notifications on status bar
Dialogue Notification − It is an activity related notification.
Status Bar Notification − It will show notifications on status bar
Dialogue Notification − It is an activity related notification.
What is viewGroup in android?
View group is a collection of views and other child views, it is an invisible part and the base class for layouts.
What is Android?
Android is a stack of software for mobile devices which includes an
Operating System,
middleware and some key applications. The application executes within
its own process and its own instance of Dalvik Virtual Machine.
Name some exceptions in android?
- Inflate Exception
- Surface.OutOfResourceException
- SurfaceHolder.BadSurfaceTypeException
- WindowManager.BadTokenException
Name the dialog box which are supported by android?
- Alert Dialog
- Progress Dialog
- Date Picker Dialog
- Time picker Dialog
What is NDK?
NDK stands for Native Development Kit. By using NDK, you can develop a
part of app using native language such as C/C++ to boost the
performance.
What is fragment?
Fragment is a part of Activity. By the help of fragments, we can display multiple screens on one activity.
What is content provider?
Content providers are used to share information between android applications.
What is the name of database used in android?
SQLite: An opensource and lightweight relational database for mobile devices.
What is service in android?
A service is a component that runs in the background. It is used to play music, handle network transaction etc
The service runs in the background indefinitely even if application is destroyed.
Moreover, service can be bounded by a component to perform interactivity and inter process communication (IPC).
The android.app.Service is subclass of ContextWrapper class.
The service runs in the background indefinitely even if application is destroyed.
Moreover, service can be bounded by a component to perform interactivity and inter process communication (IPC).
The android.app.Service is subclass of ContextWrapper class.
Note: Android service is not a thread or separate process.
What are the life cycle methods of android activity?
There are 7 life-cycle methods of activity. They are as follows:
- onCreate()
- onStart()
- onResume()
- onPause()
- onStop()
- onRestart()
- onDestroy()
What are the core building blocks of android?
The core building blocks of android are:
- Activity
- View
- Intent
- Service
- Content Provider
- Fragment etc.
Does android support other language than java?
Yes, android app can be developed in C/C++ also using android NDK
(Native Development Kit). It makes the performance faster. It should be
used with android SDK.
What are the advantages of android?
Open-source: It means no licence, distribution and development fee.
Platform-independent: It supports windows, mac and linux platforms.
Supports various technologies: It supports camera, bluetooth, wifi, speech, EDGE etc. technologies.
Highly optimized Virtual Machine: Android uses highly optimized virtual machine for mobile devices, called DVM (Dalvik Virtual Machine).
Platform-independent: It supports windows, mac and linux platforms.
Supports various technologies: It supports camera, bluetooth, wifi, speech, EDGE etc. technologies.
Highly optimized Virtual Machine: Android uses highly optimized virtual machine for mobile devices, called DVM (Dalvik Virtual Machine).
What are the code names of android?
- Aestro
- Blender
- Cupcake
- Donut
- Eclair
- Froyo
- Gingerbread
- Honycomb
- Ice Cream Sandwitch
- Jelly Bean
- Kitkat
- Lollipop
- Marshmallow
What is the difference between a regular bitmap and a nine-patch image?
In general, a 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.
What is a Sticky Intent?
Sticky Intent is also a type of intent which allows the communication
between a function and a service for example,sendStickyBroadcast() is
perform the operations after completion of intent also.
A Sticky Intent is a broadcast from sendStickyBroadcast() method such that the intent floats around even after the broadcast, allowing others to collect data from it.
A Sticky Intent is a broadcast from sendStickyBroadcast() method such that the intent floats around even after the broadcast, allowing others to collect data from it.
What data types are supported by AIDL?
AIDL has support for the following data types:
-string
-charSequence
-List
-Map
-all native Java data types like int,long, char and Boolean
-string
-charSequence
-List
-Map
-all native Java data types like int,long, char and Boolean
What is AIDL?
AIDL, or Android Interface Definition Language, handles the interface
requirements between a client and a service so both can communicate at
the same level through interprocess communication or IPC. This process
involves breaking down objects into primitives that Android can
understand. This part is required simply because a process cannot access
the memory of the other process.
How can the ANR be prevented?
One technique that prevents the Android system from concluding a code
that has been responsive for a long period of time is to create a child
thread. Within the child thread, most of the actual workings of the
codes can be placed, so that the main thread runs with minimal periods
of unresponsive times.
What is the function of an intent filter?
Because every component needs to indicate which intents they can respond
to, intent filters are used to filter out intents that these components
are willing to receive. One or more intent filters are possible,
depending on the services and activities that is going to make use of
it.
What is ANR?
ANR is short for Application Not Responding. This is actually a dialog
that appears to the user whenever an application have been unresponsive
for a long period of time.
What are the four essential states of an activity?
– Active – if the activity is at the foreground
– Paused – if the activity is at the background and still visible
– Stopped – if the activity is not visible and therefore is hidden or obscured by another activity
– Destroyed – when the activity process is killed or completed terminated
– Paused – if the activity is at the background and still visible
– Stopped – if the activity is not visible and therefore is hidden or obscured by another activity
– Destroyed – when the activity process is killed or completed terminated
What is adb?
Adb is short for Android Debug Bridge. It allows developers the power to
execute remote shell commands. Its basic function is to allow and
control communication towards and from the emulator port.
It is acts as bridge between emulator and IDE, it executes remote shell commands to run applications on an emulator
It is acts as bridge between emulator and IDE, it executes remote shell commands to run applications on an emulator
Differentiate Activities from Services.
Activities can be closed, or terminated anytime the user wishes. On the
other hand, services are designed to run behind the scenes, and can act
independently. Most services run continuously, regardless of whether
there are certain or no activities being executed.
What is the use of an activityCreator?
An activityCreator is the first step towards the creation of a new
Android project. It is made up of a shell script that will be used to
create new file system structure necessary for writing codes within the
Android IDE.
What is AAPT?
AAPT is short for Android Asset Packaging Tool. This tool provides
developers with the ability to deal with zip-compatible archives, which
includes creating, extracting as well as viewing its contents.
What is the relationship between the life cycle of an AsyncTask and an Activity? What problems can this result in? How can these problems be avoided?
An
AsyncTask is not tied to the life cycle of the Activity that contains
it. So, for example, if you start an AsyncTask inside an Activity and
the user rotates the device, the Activity will be destroyed (and a new
Activity instance will be created) but the AsyncTask will not die but instead goes on living until it completes.
Then, when the AsyncTask does complete, rather than updating the UI of the new Activity, it updates the former instance of the Activity (i.e., the one in which it was created but that is not displayed anymore!). This can lead to an Exception (of the type
There’s also the potential for this to result in a memory leak since the AsyncTask maintains a reference to the Activty, which prevents the Activity from being garbage collected as long as the AsyncTask remains alive.
For these reasons, using AsyncTasks for long-running background tasks is generally a bad idea . Rather, for long-running background tasks, a different mechanism (such as a service) should be employed.
Then, when the AsyncTask does complete, rather than updating the UI of the new Activity, it updates the former instance of the Activity (i.e., the one in which it was created but that is not displayed anymore!). This can lead to an Exception (of the type
java.lang.IllegalArgumentException
: View not attached to window manager if you use, for instance, findViewById
to retrieve a view inside the Activity).There’s also the potential for this to result in a memory leak since the AsyncTask maintains a reference to the Activty, which prevents the Activity from being garbage collected as long as the AsyncTask remains alive.
For these reasons, using AsyncTasks for long-running background tasks is generally a bad idea . Rather, for long-running background tasks, a different mechanism (such as a service) should be employed.
What is DDMS? Describe some of its capabilities.
DDMS is the Dalvik Debug Monitor Server that ships with Android. It provides a wide array of debugging features including:
The Dalvik Debug Monitor Service (DDMS) is a debugging utility that is integrate into Eclipse through a special Eclipse perspective. The DDMS perspective provides a number of useful features for interacting with emulators and handsets and debugging applications.
The feature of DDMS roughly divided into five categories as follow:-
- Task Management
- File Management
- Emulator Interaction
- Logging(LogCat)
- Screen Captures
The DDMS tool can be launched separately from Eclipse. You can find it in the Android SDK /tools directory
Describe three common use cases for using an Intent.
Common use cases for using an
Intent
include:- To start an activity: You can start a new instance of an Activity by passing an Intent to
startActivity()
method. - To start a service: You can start a service to perform a one-time operation (such as download a file) by passing an Intent to
startService()
. - To deliver a broadcast: You can deliver a broadcast to other apps by passing an Intent to
sendBroadcast()
,sendOrderedBroadcast()
, orsendStickyBroadcast()
.
Under what condition could the code sample below crash your application? How would you modify the code to avoid this potential problem? Explain your answer.
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, textMessage);
sendIntent.setType(HTTP.PLAIN_TEXT_TYPE); // "text/plain" MIME type
startActivity(sendIntent);
Answer:
An implicit intent specifies an action that can invoke any app on the device able to perform the action. Using an implicit intent is useful when your app cannot perform the action, but other apps probably can. If there is more than one application registered that can handle this request, the user will be prompted to select which one to use.
However, it is possible that there are no applications that can handle your intent. In this case, your application will crash when you invoke
startActivity()
. To avoid this, before calling startActivity()
you should first verify that there is at least one application
registered in the system that can handle the intent. To do this use resolveActivity()
on your intent object:// Verify that there are applications registered to handle this intent
// (resolveActivity returns null if none are registered)
if (sendIntent.resolveActivity(getPackageManager()) != null) {
startActivity(sendIntent);
}
Subscribe to:
Posts (Atom)