4 Andriod Lectures Notes
4 Andriod Lectures Notes
TUTORIAL QUESTIONS
Unit-1
1. What is an AVD?
2. What is the difference between the android:versionCode and android:versionName
attributes in the AndroidManifest.xml fi le?
3. What is the use of the strings.xml fi le?
4. What will happen if you have two or more activities with the same intent fi lter action
name?
5. Write the code to invoke the built-in Browser application.
6. Which components can you specify in an intent fi lter?
7. What is the diff erence between the Toast class and the NotificationManager class?
8. Name the two ways to add fragments to an activity.
9. Name one key diff erence between a fragment and an activity.
Uint-2
1. What is the diff erence between the dp unit and the px unit? Which one should you use to
specify the dimension of a view?
2. Why is the AbsoluteLayout not recommended for use?
3. What is the diff erence between the onPause()method and the onSaveInstanceState()
method?
4. Name the three methods you can override to save an activity‘s state. In what instances
should you use the various methods?
5. How do you add action items to the Action Bar?
6. How do you programmatically determine whether a RadioButton is checked?
7. How do you access the string resource stored in the strings.xml fi le?
8. Write the code snippet to obtain the current date.
9. Name the three specialized fragments you can use in your Android application and
describe their uses.
Unit-3
1. Name the two methods you need to override when implementing an options menu in your
activity.
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 166
ANDROID APPLICATION DEVELOPMENT Department of IT
2. Name the two methods you need to override when implementing a context menu in your
activity.
3. How do you prevent the WebView from invoking the device‘s web browser when a
redirection occurs in the WebView?
4. How do you display the preferences of your application using an activity?
5. Name the method that enables you to obtain the path of the external storage of an
Android device.
6. What is the permission you need to declare when writing fi les to external storage?
7. Write the query to retrieve all contacts from the Contacts application that contain the
word ―jack.‖
Unit -4
1. Name the methods that you need to override in your own implementation of a content
provider.
2. How do you register a content provider in your AndroidManifest.xml fi le?
3. Name the two ways in which you can send SMS messages in your Android application.
4. Name the permissions you need to declare in your AndroidManifest.xml fi le for sending
and receiving SMS messages.
5. How do you notify an activity from a BroadcastReceiver?
Unit -5
1. If you have embedded the Google Maps API into your Android application but it does
not show the map when the application is loaded, what could be the likely reasons?
2. What is the diff erence between geocoding and reverse geocoding?
3. Name the two location providers that you can use to obtain your location data.
4. What method is used for monitoring a location?
5. Name the permissions you need to declare in your AndroidManifest.xml fi le for an
HTTP connection.
6. Name the classes used for dealing with JSON messages.
7. Name the class for performing background asynchronous tasks.
8. Why is it important to put long-running code in a service on a separate thread?
9. What is the purpose of the IntentService class?
10. Name the three methods you need to implement in an AsyncTask class.
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 167
ANDROID APPLICATION DEVELOPMENT Department of IT
ASSISGNMENT QUESTION
UNIT-I
1. What is an AVD?
2. What is the difference between the android:versionCode and android:versionName
attributes in the AndroidManifest.xml fi le?
3. What is the use of the strings.xml fi le?
4. What will happen if you have two or more activities with the same intent fi lter action
name?
5. Write the code to invoke the built-in Browser application.
6. Which components can you specify in an intent fi lter?
7. What is the diff erence between the Toast class and the NotificationManager class?
8. Name the two ways to add fragments to an activity.
9. Name one key diff erence between a fragment and an activity.
UNIT-II
1. What is the diff erence between the dp unit and the px unit? Which one should you use to
specify the dimension of a view?
2. Why is the AbsoluteLayout not recommended for use?
3. What is the diff erence between the onPause()method and the onSaveInstanceState()
method?
4. Name the three methods you can override to save an activity‘s state. In what instances
should you use the various methods?
5. How do you add action items to the Action Bar?
6. How do you programmatically determine whether a RadioButton is checked?
7. How do you access the string resource stored in the strings.xml fi le?
8. Write the code snippet to obtain the current date.
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 168
ANDROID APPLICATION DEVELOPMENT Department of IT
9. Name the three specialized fragments you can use in your Android application and
describe their uses.
UNIT-III
1. Name the two methods you need to override when implementing an options menu in your
activity.
2. Name the two methods you need to override when implementing a context menu in your
activity.
3. How do you prevent the WebView from invoking the device‘s web browser when a
redirection occurs in the WebView?
4. How do you display the preferences of your application using an activity?
5. Name the method that enables you to obtain the path of the external storage of an
Android device.
6. What is the permission you need to declare when writing fi les to external storage?
7. Write the query to retrieve all contacts from the Contacts application that contain the
word ―jack.‖
UNIT-IV
1. Name the methods that you need to override in your own implementation of a content
provider.
2. How do you register a content provider in your AndroidManifest.xml fi le?
3. Name the two ways in which you can send SMS messages in your Android application.
4. Name the permissions you need to declare in your AndroidManifest.xml fi le for sending
and receiving SMS messages.
5. How do you notify an activity from a BroadcastReceiver?
UNIT-V
1. If you have embedded the Google Maps API into your Android application but it does
not show the map when the application is loaded, what could be the likely reasons?
2. What is the diff erence between geocoding and reverse geocoding?
3. Name the two location providers that you can use to obtain your location data.
4. What method is used for monitoring a location?
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 169
ANDROID APPLICATION DEVELOPMENT Department of IT
OBJECTIVE QUESTIONS
UNIT-1
1) Once installed on a device, each Android application lives in_______?
a)device memory
b)external memory
c) security sandbox
d)None of the above
Ans) c
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 170
ANDROID APPLICATION DEVELOPMENT Department of IT
b) ActivityGroup
c) ExpandableListActivity
d) FragmentActivity
e) ListActivity
f) all the aove
Ans) f
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 171
ANDROID APPLICATION DEVELOPMENT Department of IT
Ans) c
8)When contentProvider would be activated?
a)Using Intent
b)Using SQLite
c)Using ContentResolver
d)None of the above
Ans) c
9)Which of the important device characteristics that you should consider as you design and
develop your application?
a)Screen size and density
b)Input configurations
c)Device features
d)Platform Version
e)All of the above
Ans) e
10)Which are the screen sizes in Android?
a)small
b)normal
c)large
d)extra large
e)All of the above
Ans) e
11)Which are the screen densities in Android?
a)low density
b)medium density
c)high density
d)extra high density
e)All of the above
Ans) e
12)You can shut down an activity by calling its _______ method
a)onDestory()
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 172
ANDROID APPLICATION DEVELOPMENT Department of IT
b)finishActivity()
c)finish()
d)None of the above
Ans) c
13)What is the difference between Activity context and Application Context?
a) The Activity instance is tied to the lifecycle of an Activity.
while the application instance is tied to the lifecycle of the application,
b) The Activity instance is tied to the lifecycle of the application,
while the application instance is tied to the lifecycle of an Activity.
c) The Activity instance is tied to the lifecycle of the Activity,
while the application instance is tied to the lifecycle of an application.
d) None of the above
Ans) a
14)Which one is NOT related to fragment class?
a)DialogFragment
b)ListFragment
c)PreferenceFragment
d)CursorFragment
Ansa)d
15)Definition of Loader?
a) loaders make it easy to asynchronously load data in an activity or fragment.
b) loaders make it easy to synchronously load data in an activity or fragment.
c) loaders does not make it easy to asynchronously load data in an activity or fragment.
d) None of the above.
Ans) a
16)Characteristics of the Loaders?
a)They are available to every Activity and Fragment.
b)They provide asynchronous loading of data.
c)They monitor the source of their data and deliver new results when the content changes.
d)They automatically reconnect to the last loader's cursor when being recreated after a
configuration change. Thus, they don't need to re-query their data.
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 173
ANDROID APPLICATION DEVELOPMENT Department of IT
18)If your service is private to your own application and runs in the same process as the client
(which is common), you should create your interface by extending the ________class?
a) Messenger
b) Binder
c) AIDL
d)None of the above
Ans) b
19)If you need your interface to work across different processes, you can create an interface for
the service with a ________?
a)Binder
b)Messenger
c)AIDL
d) b or c
Ans) d
20)AsyncTask allows you to perform asynchronous work on your user interface. It performs the
blocking operations in a worker thread and then publishes the results on the UI thread.
a)true
b)false
Ans) a
UNIT-II
Q1. What method you should override to use Android menu
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 174
ANDROID APPLICATION DEVELOPMENT Department of IT
system?
a. onCreateOptionsMenu()
b. onCreateMenu()
c. onMenuCreated()
d. onCreateContextMenu()
Answer: A
a. findViewByReference(int id);
b. findViewById(int id)
c. retrieveResourceById(int id)
d. findViewById(String id)
Answer: B
a. Service
b. Activity
c. Layout
d. Content Provider
Answer: C
Q4. During an Activity life-cycle, what is the first callback method invoked by the system?
a. onStop()
b. onStart()
c. onCreate()
d. onRestore()
Answer: C
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 175
ANDROID APPLICATION DEVELOPMENT Department of IT
Q10. What is the name of the folder that contains the R.java file?
a. src
b. res
c. bin
d. gen
Answer: D
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 176
ANDROID APPLICATION DEVELOPMENT Department of IT
Answer: D
Q19.Which of these files contains text values that you can use in
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 177
ANDROID APPLICATION DEVELOPMENT Department of IT
your application?
a. AndroidManifest.xml
b. res/Text.xml
c. res/layout/Main.xml
d. res/values/strings.xml
Answer: D
UNIT-III
Q1. What does this code do?
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(android.net.Uri.parse("http://www.androidatc.com"));
startActivity(intent);
a. Starts a sub-activity
b. Starts a service
c. Sends results to another activity.
d. Starts an activity using an implicit intent.
Answer: D
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 178
ANDROID APPLICATION DEVELOPMENT Department of IT
b. Finish( )
c. Stop( )
d. Close( )
Answer: B
Q5. Which of the following Activity life-cycle methods is called once the
activity is no longer visible?
a. onStop
b. onPause
c. onDestroy
d. onHide
Answer: A
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 179
ANDROID APPLICATION DEVELOPMENT Department of IT
b. myWebView.getJavaScriptSettings.setEnabled(true)
c. myWebView.getSettings().setJavaScriptEnabled(true);
d. Java script is always enabled in WebView
Answer: C
Q12. When using an implicit intent, what process does the system use to
know what to do with it?
a. Intent resolution
b. Intent declaration
c. Intent overloading
d. Intent transition
Answer: A
Q15. The DalvikVM core libraries are a subset of which of the following?
a. Java ME
b. Java SE
c. Java EE
d. JAX-WS
Answer: B
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 180
ANDROID APPLICATION DEVELOPMENT Department of IT
Q16. Which of the following is correct about file access in the Android
system?
a. Generally, files are handled as dedicated resources per each application.
b. Files created by an application can be directly accessed by any application.
c. The content of file created by application cannot be accessed by any other
application.
d. You can only access a file from within an Activity.
Answer: A
UNIT-IV
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 181
ANDROID APPLICATION DEVELOPMENT Department of IT
4. Which package of the following does not have classes needed for
Android network connections?
a. java.net
b. org.apache.http
c. android.location
d. android.net
Answer: C
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 182
ANDROID APPLICATION DEVELOPMENT Department of IT
10. Which of the following lines of code starts activity Activity2 from a
current activity Activity1?
a. Intent intent = new Intent(this,new Activity2());
startActivity(intent);
b. Intent intent = new Intent(new Activity2());
startActivity(intent);
c. Intent intent = new Intent (Activity1.class,Activity2.class);
startActivity(intent);
d. Intent intent = new Intent(this,Activity2.class);
startActivity(intent);
Answer: d
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 183
ANDROID APPLICATION DEVELOPMENT Department of IT
17. Which of the following Android View sub-classes uses the WebKit
rendering engine to display web pages?
aPageView
b.WebView
c. MapView
d. HttpClient
Answer: B
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 184
ANDROID APPLICATION DEVELOPMENT Department of IT
b.webView.getSettings().setZoomControls(true);
c.webView.getZoomSettings().setControls(CONTROLS.enabled);
19. Which of the following best explains the Android option menus?
a. It is a popup menu that displays a list of items in a vertical list anchored to the view that
invoked the menu.
b. It is a floating menu that appears when the user performs a long-click on an element. It
provides actions that affect the selected content or context frame.
c. It is the primary collection of menu items for an activity where you should place actions
that have a global impact on the app, such as "Search," "Compose email," and
"Settings."
d. It is a type of List Activity with predefined headers and footers for special commands.
Answer: c
20. Which of the following best explains the Android context menus?
a. It is a popup menu displays a list of items in a vertical list that's anchored to the view
that invoked the menu.
b. It is a floating menu that appears when the user performs a long-click on an element. It
provides actions that affect the selected content or context frame.
c. It is the primary collection of menu items for an activity. It's where you should place
actions that have a global impact on the app, such as "Search," "Compose email," and
"Settings."
d. It is a sub-menu of an options menu item.
Answer: B
UNIT-V
1. Which of the following applies a context menu on a ListView?
(Choose two)
a. ListView lv = getListView();
lv.registerForContextMenu()
b. ListView lv= getListView();
registerForContextMenu(lv);
c. ListView lv = (ListView) findViewById(R.id.list_view_id);
registerForContextMenu(lv)
d. getListView().setConextMenuEnabled(true)
Answer: B & C
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 185
ANDROID APPLICATION DEVELOPMENT Department of IT
menu.setHeaderTitle("Menu");
AdapterContextMenuInfo cmi = (AdapterContextMenuInfo) menuInfo;
menu.add(1, cmi.position, 0, "Open file");
menu.add(2, cmi.position, 0, "Save file");
}
Which of the following best explains the code above?
A)The code inflates an xml file into menu items
B)The code creates menu items for context menu programmatically
C)The code assign actions to menu items
D)The code Opens a menu resource file, modifies it, and saves the changes.
Answer: B
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 186
ANDROID APPLICATION DEVELOPMENT Department of IT
10. Which of the following you cannot achieve by creating your own View
sub-classes?
a. Create a completely new customized View type.
b. Combine a group of View components into a new single component.
c. Specify when to destroy an activity and all its views.
d. Override the way that an existing component is displayed on the screen.
Answer: C
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 187
ANDROID APPLICATION DEVELOPMENT Department of IT
b. onPostExecute()
c. publishProgress()
d. onProgressUpdate()
Answer: C
15. Which of the following is true about the Dialog class? (Choose two)
a. You can add a custom layout to a dialog using setContentView().
b. A dialog has a life-cycle independent of the Activity.
c. A dialog is displayed on the screen using method show().
d. It does not have a method to access the activity that owns it.
Answer: A & C
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 188
ANDROID APPLICATION DEVELOPMENT Department of IT
20.Multiple inheritance is not allowed in Java therefore in an android activity there cannot be
more then one
A.super class
B.child class
C.sub class
D.public clas
Answer C
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 189
ANDROID APPLICATION DEVELOPMENT Department of IT
UNIT-II
1. What is the diff erence between the dp unit and the px unit? Which one should you use to
specify the dimension of a view?
2. Why is the AbsoluteLayout not recommended for use?
3. What is the diff erence between the onPause()method and the onSaveInstanceState()
method?
4. Name the three methods you can override to save an activity‘s state. In what instances
should you use the various methods?
5. How do you add action items to the Action Bar?
6. How do you programmatically determine whether a RadioButton is checked?
7. How do you access the string resource stored in the strings.xml fi le?
8. Write the code snippet to obtain the current date.
9. Name the three specialized fragments you can use in your Android application and
describe their uses.
UNIT-III
1. Name the two methods you need to override when implementing an options menu in your
activity.
2. Name the two methods you need to override when implementing a context menu in your
activity.
3. How do you prevent the WebView from invoking the device‘s web browser when a
redirection occurs in the WebView?
4. How do you display the preferences of your application using an activity?
5. Name the method that enables you to obtain the path of the external storage of an
Android device.
6. What is the permission you need to declare when writing fi les to external storage?
7. Write the query to retrieve all contacts from the Contacts application that contain the
word ―jack.‖
UNIT-IV
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 190
ANDROID APPLICATION DEVELOPMENT Department of IT
1. Name the methods that you need to override in your own implementation of a content
provider.
2. How do you register a content provider in your AndroidManifest.xml fi le?
3. Name the two ways in which you can send SMS messages in your Android application.
4. Name the permissions you need to declare in your AndroidManifest.xml fi le for sending
and receiving SMS messages.
5. How do you notify an activity from a BroadcastReceiver?
UNIT-V
1. If you have embedded the Google Maps API into your Android application but it does
not show the map when the application is loaded, what could be the likely reasons?
2. What is the diff erence between geocoding and reverse geocoding?
3. Name the two location providers that you can use to obtain your location data.
4. What method is used for monitoring a location?
5. Name the permissions you need to declare in your AndroidManifest.xml fi le for an
HTTP connection.
6. Name the classes used for dealing with JSON messages.
7. Name the class for performing background asynchronous tasks.
8. Why is it important to put long-running code in a service on a separate thread?
9. What is the purpose of the IntentService class?
10. Name the three methods you need to implement in an AsyncTask class.
11. How can a service notify an activity of an event happening?
12. For threading, what is the recommended method to ensure that your code runs without
tying up the UI of your application?
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 191
ANDROID APPLICATION DEVELOPMENT Department of IT
INTERNAL PAPERS
MALLA REDDY ENGINEERING COLLEGE FOR WOMEN
AUTONOMOUS INSTITUTION-UGC, GOVT. OF INDIA
DEPARTMENT OF IT
MID EXAM
SUB: Android App. Program CLASS/SEM/BRACH: IV-I IT
DATE: SECTION: IT
TIME: 90MIN MARKS: 40 marks
PART-A
PART-B
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 192
ANDROID APPLICATION DEVELOPMENT Department of IT
PART-A
PART-B
6. If you have embedded the Google Maps API into your Android application but it does
not show the map when the application is loaded, what could be the likely reasons?
OR
7. What is the diff erence between geocoding and reverse geocoding?
8. Name the two location providers that you can use to obtain your location data.
What method is used for monitoring a location?
OR
9. Name the two methods you need to override when implementing an options menu in your
activity.
10. Name the two methods you need to override when implementing a context menu in your
activity.
OR
11. How do you prevent the WebView from invoking the device‘s web browser when a
redirection occurs in the WebView?
Malla Reddy Engineering College for Women (Autonomous Institution-UGC, Govt. of India) Page 193