CAT II Question Bank
CAT II Question Bank
The role of the content provider in the android system is like a central repository in
which data of the applications are stored, and it facilitates other applications to securely
access and modifies that data based on the user requirements.
This means that you can check on the values of variables in your application while you
are debugging it. Also, you can check whether certain lines of code are being executed
as expected – or at all.
13. What is the purpose of intent object?
Intent is used to move from screen to screen.Intent describes what an application does.
The action and the data to act upon are the two most important parts of the
intent.Typical values for action are MAIN,VIEW,PICK,EDIT,etc
The data is expressed as a Unifrom Resource Indicator(URI)
Intent intent=new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("https://www.w3schools.com/"));
startActivity(intent);
14. What is table layout?
The TableLayout Layout groups views into rows and columns. You use the element
to designate a row in the table. Each row can contain one or more views. Each view you
place within a row forms a cell. The width of each column is determined by the largest
width of each cell in that column.
15. How can the viewgroup be classified?
ViewGroups are classified into
1. Basic Views
2. Picker Views
3. List Views
4. Specialized Fragments
16. What are the differences between the options menu and context menu?
Android Options Menu is a primary collection of menu items in an android
application and is useful for actions that have a global impact on the searching
application.
Android Context Menu is a floating menu that only appears when the user clicks for
a long time on an element and is useful for elements that affect the selected content or
context frame.
17. What do you mean by content providers?
Content Providers are a very important component that serves the purpose of a
relational database to store the data of applications.
The role of the content provider in the android system is like a central repository in
which data of the applications are stored, and it facilitates other applications to
securely access and modifies that data based on the user requirements.
It is the modular section of the android activity that is very helpful in creating UI
designs that are flexible in nature and auto-adjustable based on the device screen size
Front-end Languages
The Languages used for front end development are
o HTML
o CSS
o JavaScript
Provide the Good look and feel of the mobile app
Front end development is depending on the frameworks such as Dart in flutter,
Javascript in React, Python in Django and so on
HTML
CSS
CSS stands for Cascading Style Sheets.
It is the language for describing the presentation of Web pages, including colours,
layout, and fonts, thus making web pages presentable to the users.
CSS is designed to make style sheets for the web.
It is independent of HTML and can be used with any XML-based markup language.
o Cascading: Falling of Styles
o Style: Adding designs/Styling the HTML tags
o Sheets: Writing the style in different documents
CSS handles the look and feel part of a web page.
Using CSS, user can control the color of the text, the style of fonts, the spacing
between paragraphs, how columns are sized and laid out, what background images or
colors are used, layout designs, variations in display for different devices and screen
sizes as well as a variety of other effects.
JavaScript
o JavaScript is a lightweight, cross-platform, single-threaded, and interpreted
compiled programming language.
o It is also known as the scripting language for webpages.
o It is well-known for the development of web pages
o JavaScript is a weakly typed language (dynamically typed).
o JavaScript can be used for Client-side developments as well as Server-
side developments
import androidx.appcompat.app.AppCompatActivity;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View
ViewGroup
act as a base class for layouts and layouts parameters that hold other Views or
ViewGroups and to define the layout properties.
They are Generally Called layouts.
Types of layout
There are many types of layout.
o Linear Layout
o Absolute Layout
o Table Layout
o Frame Layout
o Relative Layout
Function Description
sendTextMessage(String destinationAddress,
sendTextMessage() String scAddress, String text, PendingIntent sentIntent,
PendingIntent deliveryIntent, long messageId)
sendDataMessage(String destinationAddress,
sendDataMessage() String scAddress, short destinationPort, byte[] data,
PendingIntent sentIntent, PendingIntent deliveryIntent)
Function Description
sendMultimediaMessage(Context context,
sendMultimediaMessage() Uri contentUri, String locationUrl,
Bundle configOverrides, PendingIntent sentIntent
SmsManager API
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage("phoneNo", null, "sms message", null, null);
Built-in SMS application
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.putExtra("sms_body", "default content");
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);
Note, both need SEND_SMS permission.
<uses-permission android:name="android.permission.SEND_SMS" />
The list items are automatically inserted to the list using an Adapter that pulls content
from a source such as an array or database.
ListView Attributes
android:id
This is the ID which uniquely identifies the layout.
android:divider
This is drawable or color to draw between list items.
android:dividerHeight
This specifies height of the divider. This could be in px, dp, sp, in, or mm.
android:entries
Specifies the reference to an array resource that will populate the ListView.
android:footerDividersEnabled
When set to false, the ListView will not draw the divider before each footer view. The
default value is true.
android:headerDividersEnabled
When set to false, the ListView will not draw the divider after each header view. The
default value is true.
update() This method is used to update the fields of an existing row. It returns
Abstract
Method Description
This method is used to delete the existing rows. It returns the number
delete() of rows deleted.
SQLite is a opensource SQL database that stores data to a text file on a device.
Android comes in with built in SQLite database implementation.
SQLite supports all the relational database features.
In order to access this database, don't need to establish any kind of connections for it
like JDBC,ODBC e.t.c
Database - Package
The main package is android.database.sqlite that contains the classes to manage
the databases
Database - Creation
o In order to create a database just need to call the method
openOrCreateDatabase with database name and mode as a parameter.
o It returns an instance of SQLite database
Syntax (String,
getColumnCount()
This method return the total number of columns of the table.
getColumnIndex(String columnName)
This method returns the index number of a column by specifying
the name of the column
getColumnName(int columnIndex)
This method returns the name of the column by specifying the
index of the column
getColumnNames()
This method returns the array of all the column names of the table.
getCount()
This method returns the total number of rows in the cursor
getPosition()
This method returns the current position of the cursor in the table
isClosed()
This method returns true if the cursor is closed and return false
otherwise
Create a Timer object and call its scheduleAtFixedRate() method inside the
doSomethingRepeatedly() method that you have defined:
private void doSomethingRepeatedly() {
timer.scheduleAtFixedRate( new TimerTask() {
public void run() {
Log.d("MyService", String.valueOf(++counter));
}
}, 0, UPDATE_INTERVAL);
}
Pass an instance of the TimerTask class to the scheduleAtFixedRate() method so that you
can repeatedly execute the block of code within the run() method. The second parameter to
the scheduleAtFixedRate() method specifies the amount of time, in milliseconds, before first
execution. The third parameter specifies the amount of time, in milliseconds, between
subsequent executions.
In the preceding example, you essentially print the value of the counter every second (1,000
milliseconds). The service repeatedly prints the value of counter until the service is
terminated:
@Override
public void onDestroy() {
super.onDestroy();
if (timer != null){
timer.cancel();
}
Toast.makeText(this, "Service Destroyed", Toast.LENGTH_LONG).show();
}
For the scheduleAtFixedRate() method, your code is executed at fixed time intervals,
regardless of how long each task takes. For example, if the code within your run() method
takes two seconds to complete, then your second task starts immediately after the first task
has ended. Similarly, if your delay is set to three seconds and the task takes two seconds to
complete, then the second task waits for one second before starting.
4. Summarize front end languages and framework for mobile app development
Front-end Languages
The Languages used for front end development are
o HTML
o CSS
o JavaScript
Provide the Good look and feel of the mobile app
Front end development is depending on the frameworks such as Dart in flutter,
Javascript in React, Python in Django and so on
HTML
CSS
CSS stands for Cascading Style Sheets.
It is the language for describing the presentation of Web pages, including colours,
layout, and fonts, thus making web pages presentable to the users.
CSS is designed to make style sheets for the web.
It is independent of HTML and can be used with any XML-based markup language.
o Cascading: Falling of Styles
o Style: Adding designs/Styling the HTML tags
o Sheets: Writing the style in different documents
CSS handles the look and feel part of a web page.
Using CSS, user can control the color of the text, the style of fonts, the spacing
between paragraphs, how columns are sized and laid out, what background images or
colors are used, layout designs, variations in display for different devices and screen
sizes as well as a variety of other effects.
JavaScript
o JavaScript is a lightweight, cross-platform, single-threaded, and interpreted
compiled programming language.
o It is also known as the scripting language for webpages.
o It is well-known for the development of web pages
o JavaScript is a weakly typed language (dynamically typed).
o JavaScript can be used for Client-side developments as well as Server-
side developments
Frameworks or libraries in app development provide developers with the right tools to help
them in the development process of application.
ReactJS
ReactJS, is a JavaScript library specifically designed for building user interfaces (UI) that are
quick easily customizable and flexible. ReactJs is an open source component based frontend
library that is only responsible for application’s view layer.
Angular JS
AngularJs is an open source JavaScript front-end framework that is mostly used to create
single page web applications. It is a framework that is always evolving and providing better
ways to develop online applications. The static HTML is replaced by dynamic HTML. It adds
directives to HTML attributes and uses HTML to bind data.
jQuery
jQuery is a free JavaScript framework that makes it easier to handle HTML/CSS documents.
It simplifies HTML documents manipulation,browser event handling, DOM animations and
cross-browser JavaScript programming.
android:screenOrientation="orientation_type">
</activity>
Example:
android:screenOrientation="orientation_type">
two activities of different screen orientation.
o The first activity will be as ―portrait‖ orientation and
o Second activity as ―landscape‖ orientation state.
Step-by-Step demonstration:
Creating the activities: There will be two activities and hence two XML files, one for
each activity.
1. activity_main.xml: XML file for first activity consist of constraint layout with Button
and Text View in it. This activity is in Landscape state.
2. activity_next.xml: XML file for second activity consist of constraint layout with Text
View in it. This activity is in Landscape state.
Creating the Java file: There will be two activities and hence two Java files, one for each
activity.
1. MainActivity.java: Java file for Main Activity, in which setOnClick() listener is
attached to the button to launch next activity with different orientation.
2. NextActivity.java: Java file for Next Activity which is in Landscape mode.
Updating the AndroidManifest file:
In AndroidManifest.xml file, add the screenOrientation state in activity along with its
orientation.
Here, provide ―portrait‖ orientation for MainActivity and ―landscape‖ for
NextActivity.
Consuming JSON services in Android (or in any web-based application) refers to retrieving
data in the JSON (JavaScript Object Notation) format from a remote server and using it
within your application. JSON is a lightweight, human-readable data interchange format
commonly used for exchanging data between a client (your app) and a server.
Remote Data Retrieval: JSON is widely used in web APIs to exchange data. By
consuming JSON services, an Android app can retrieve data from remote servers or
web services. For example, an app might fetch data from a server (such as weather
information, news articles, or product data) in JSON format.
Real-time Updates: JSON services allow apps to get up-to-date data from the server.
For example, social media apps or messaging apps often use JSON APIs to fetch the
latest posts, chats, or notifications in real time.
2. Standardized Data Exchange Format
3. Dynamic Content
Customizable Data: JSON allows flexible, dynamic content. The data returned can
be in the form of a list, object, or even nested data, and this can be tailored to the
app’s needs (e.g., querying a specific subset of information from the server). This
gives apps the ability to display dynamic data that can change or be customized based
on user interaction or other factors.
Interactive Features: Many modern apps rely on consuming JSON data to offer
interactive and customizable experiences, such as dynamic forms, content filters, or
user-specific data (e.g., user preferences or profiles).