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

1. Describe Android application Architecture?

10 marks
2. A. Explain Activity life cycle in android? 7 marks
B. What is An Intent? Define Types of intents? 3 marks
3. Explain the following?
a. Dalvik virtual Machine.4M
DVM

The Dalvik Virtual Machine (DVM) is an android virtual machine optimized for mobile
devices. It optimizes the virtual machine for memory, battery life and performance.

The Dex compiler converts the class files into the .dex file that run on the Dalvik VM.
Multiple class files are converted into one dex file.(1 mark)

2marks

The javac tool compiles the java source file into the class file.

The dx tool takes all the class files of your application and generates a single.dex file. It
is a platform-specific tool.

The Android Assets Packaging Tool (aapt) handles the packaging process.

Dalvik virtual machine uses register based architecture. With this architecture dalvik
virtual machine has few advantages over JAVA virtual machine such as:

1. Dalvik uses its own 16 bit instruction set than java 8 bit stack instructions, which reduce
the dalvik instruction count and raised its interpreter speed.
2. Dalvik use less space, which means an uncompressed. dex file is smaller in size (few
bytes) than compressed java archive file(.jar file). (1mark)

b. DDMS.2M
DDMS
The Dalvik Debug Monitor Service (DDMS) is a debugging tool used in the Android

platform. The Dalvik Debug Monitor Service is downloaded as part of the Android SDK.

Some of the services provided by the DDMS are

1. port forwarding,

2. on-device screen capture,

3. on-device thread and heap monitoring,

4. radio state information.

5. Incoming call, SMS

6. Location data spoofing

The Dalvik Debug Monitor Service allows developers to spot bugs in applications

running on either an emulator or an actual Android device.

For example, by using the DDMS’ LogCat feature, developers can view log messages

regarding the state of the application and the device. LogCat can pinpoint the exact

line number on which an error occurred.

Another DDMS feature, known as the Emulator Control, allows developers to simulate

phone states and activities. For example, it can simulate different types of networks
such as GPRS, EDGE, and UTMS, which can have different network characteristics

such as speed and latency. (3 marks)

c. List any two features of Android sdk.2M


d. ADB. 2M
ADB
Android Debug Bridge (adb) is a versatile command-line tool that lets you communicate

with a device. The adb command facilitates a variety of device actions, such as installing

and debugging apps, and it provides access to a Unix shell that you can use to run a

variety of commands on a device. It is a client-server program that includes three

components:

 A client, which sends commands. The client runs on your development machine. You

can invoke a client from a command-line terminal by issuing an adb command.

 A daemon (adbd), which runs commands on a device. The daemon runs as a

background process on each device.

 A server, which manages communication between the client and the daemon. The

server runs as a background process on your development machine.

adb is included in the Android SDK Platform-Tools package. (3 marks)

4. a. What is Layout? List out different Layouts supported by Android


system also explain with its various attributes. 5m
b. What is AndroidManifest.xml? Write its usages with an appropriate.
example.5m
5. Create simple registration form, pass and display those all entered data in
another activity using intent. Illustrate the same. 10 marks
6. What is List view. Write a java class to add any 10 items within List view.
7. How to create menus in android? explain with example.
Ans:

Android Option Menus are the primary menus of android. They can be used for settings,

search, delete item etc.

Here, we are inflating the menu by calling the inflate() method of MenuInflater class.

To perform event handling on menu items, you need to

override onOptionsItemSelected() method of Activity class.

 menu_main.xml
 <menu xmlns:androclass="http://schemas.android.com/apk/res/android" >
 <item android:id="@+id/item1"
 android:title="Item 1"/>
 <item android:id="@+id/item2"
 android:title="Item 2"/>
 <item android:id="@+id/item3"
 android:title="Item 3"/>
 </menu>

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);//Menu Resource, Menu
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.item1:
Toast.makeText(getApplicationContext(),"Item 1 Selected",Toast.LENGTH_LON
G).show();
return true;
case R.id.item2:
Toast.makeText(getApplicationContext(),"Item 2 Selected",Toast.LENGTH_LO
NG).show();
return true;
case R.id.item3:
Toast.makeText(getApplicationContext(),"Item 3 Selected",Toast.LENGTH_LO
NG).show();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}

8. What is SQLite database? Write code for adding, updating and removing
data from SQLite database.
Ans:
SQLite is a well-regarded relational database management system (RDBMS).

It is:

1. Open-source

2. Standards-compliant

3. Lightweight

4. Single-tier

It has been implemented as a compact C library that’s included as part of the

Android software stack. By being implemented as a library, rather than running

as a separate ongoing process, each SQLite database is an integrated part of the

application that created it. This reduces external dependencies, minimizes

latency, and simplifies transaction locking and synchronization. SQLite has a


reputation for being extremely reliable and is the database system of choice for

many consumer electronic devices, including many MP3 players and

smartphones. (2 marks)

Inserting Rows To create a new row, construct a Content Values object and use

its put methods to add name/value pairs representing each column name and its

associated value. Insert the new row by passing the Content Values into the

insert method called on the target database — along with the table name — as

shown in

Inserting new rows into a database

// Create a new row of values to insert.

ContentValues newValues = new ContentValues();

// Assign values for each row.

newValues.put(KEY_GOLD_HOARD_NAME_COLUMN, hoardName);

newValues.put(KEY_GOLD_HOARDED_COLUMN, hoardValue);

newValues.put(KEY_GOLD_HOARD_ACCESSIBLE_COLUMN, hoardAccessible);

// [ ... Repeat for each column / value pair ... ]

// Insert the row into your table

SQLiteDatabase db = hoardDBOpenHelper.getWritableDatabase();

db.insert(HoardDBOpenHelper.DATABASE_TABLE, null, newValues);

The second parameter used in the insert method known as the null column hack.

If you want to add an empty row to an SQLite database, by passing in an empty

Content Values object, you must also pass in the name of a column whose value

can be explicitly set to null.

When inserting a new row into an SQLite database, you must always explicitly

specify at least one column and a corresponding value, the latter of which can be

null. If you set the null column hack parameter to null, when inserting an empty

Content Values object SQLite will throw an exception. It’s generally good practice
to ensure that your code doesn’t attempt to insert empty Content Values into an

SQLite database.

Updating Rows Updating rows is also done with Content Values. Create a new

ContentValues object, using the put methods to assign new values to each

column you want to update. Call the update method on the database, passing in

the table name, the updated Content Values object, and a where clause that

specifi es the row(s) to update,

// Create the updated row Content Values.

ContentValues updatedValues = new ContentValues();

// Assign values for each row.

updatedValues.put(KEY_GOLD_HOARDED_COLUMN, newHoardValue);

// [ ... Repeat for each column to update ... ]

// Specify a where clause the defines which rows should be

// updated. Specify where arguments as necessary.

String where = KEY_ID + “=” + hoardId;

String whereArgs[] = null;

// Update the row with the specified index with the new values.

SQLiteDatabase db = hoardDBOpenHelper.getWritableDatabase();

db.update(HoardDBOpenHelper.DATABASE_TABLE, updatedValues, whereArgs);

Deleting Rows To delete a row, simply call the delete method on a database,

specifying the table name and a where clause that returns the rows you want to

delete,

Deleting a database row

// Specify a where clause that determines which row(s) to delete.

// Specify where arguments as necessary.

String where = KEY_GOLD_HOARDED_COLUMN + “=” + 0; String whereArgs[] =

null;

// Delete the rows that match the where clause.


SQLiteDatabase db = hoardDBOpenHelper.getWritableDatabase();

db.delete(HoardDBOpenHelper.DATABASE_TABLE, where, whereArgs); (5marks)

9. Explain features of Android? Explain android sdk features.


10. Explain android development tools.
11. Write a note on Service life cycle.
12. Explain how to configure intent-filter in AndroidManifest.xml file with
example.
13.What is Emulator? Explain in briefely.
14.How Android supports multiple screen? Explain with an appropriate
example
15.Define Adapters? Explain types of Adapters?

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