0% found this document useful (0 votes)
2 views6 pages

mad viva

Uploaded by

Psykick Gaming
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views6 pages

mad viva

Uploaded by

Psykick Gaming
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1. What is Android?

Answer: Android is an open-source operating system based on Linux, designed primarily for
touchscreen mobile devices such as smartphones and tablets. It is developed by Google.

[Link] are the four main components of an Android application?

The four main components are:

a)Activities
b)Services
c)Broadcast Receivers
d)Content Providers

[Link] is an Activity in Android?

An Activity is a single, focused thing that the user can do. Almost all activities interact with
the user, so the Activity class takes care of creating a window for you in which you can place
your UI.

[Link] the lifecycle of an Android activity.

The lifecycle includes the following states:


onCreate()
onStart()
onResume()
onPause()
onStop()
onRestart()
onDestroy()

[Link] is the purpose of an Intent in Android?

An Intent is an abstract description of an operation to be performed. It can be used with


startActivity to launch an Activity, startService(Intent) to start a Service, and
sendBroadcast(Intent) to send a broadcast.

[Link] is the difference between implicit and explicit Intent?

Explicit Intents specify the component to be invoked from the application, while implicit
Intents declare a general action to perform, which allows a component from another app to
handle it.

7. What is a Content Provider and how is it used?

A Content Provider manages access to a structured set of data. It can be used to share data
between different applications.

8. Explain the concept of Services in Android.


A Service is an application component that can perform long-running operations in the
background and does not provide a user interface.

[Link] is a BroadcastReceiver?

A BroadcastReceiver is an Android component that allows you to register for system or


application events. All registered receivers for an event are notified by the Android runtime
once this event happens.
[Link] do you define a user interface in Android?

A user interface in Android is defined using XML files. Each component in the UI is
represented by an XML element and attributes define its properties.
11.
What is the purpose of the [Link] file?

The [Link] file provides essential information about the app to the Android
system, which the system must have before it can run any of the app's code.

[Link] do you handle different screen sizes in Android?

Different screen sizes are handled using different resource directories (such as res/layout,
res/layout-large, res/layout-xlarge, etc.) and by using density-independent pixels (dp) and
scalable resources.

[Link] a simple example of an Android activity in Java.

package [Link];

import [Link];
import [Link];

public class MainActivity extends Activity {


@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
}
}

[Link] do you start a new activity and pass some data to it?

Intent intent = new Intent([Link], [Link]);


[Link]("key", "value");
startActivity(intent);

[Link] how to use the RecyclerView in Android.

RecyclerView is a more advanced and flexible version of ListView. It requires:


LayoutManager: Positions items.
Adapter: Binds the data to the RecyclerView.
ViewHolder: Holds the view for each item

[Link] is an Android application?

Answer: An Android application is a software application running on the Android platform. It


is designed for use on smartphones and tablets.

[Link] programming language is primarily used for Android development?

Answer: The primary programming language used for Android development is Java. Kotlin is
also commonly used.
[Link] is the Android SDK?

Answer: The Android Software Development Kit (SDK) is a set of development tools used to
develop applications for the Android platform.

[Link] is an APK file?

Answer: APK (Android Package Kit) is the package file format used by the Android
operating system for distribution and installation of mobile apps
[Link] is an Activity in Android?

Answer: An Activity is a single screen in an Android app with which users can interact.
[Link] is the role of onCreate() method in an Activity?

Answer: The onCreate() method is called when the activity is first created. It is where you
should perform all initialization of the activity, such as setting up the UI.

[Link] is a View in Android?

Answer: A View is a basic building block for user interface components in Android.
Examples include buttons, text fields, and images.

[Link] is an Intent?

Answer: An Intent is a messaging object used to request an action from another app
component, such as starting a new activity or sending data.

[Link] is a Toast in Android?

Answer: A Toast is a small popup message that appears for a short duration to provide
feedback to the user.

[Link] is an Android Emulator?

Answer: An Android Emulator is a virtual device that mimics the hardware and software of
an Android phone or tablet, allowing developers to test apps without needing a physical
device.

[Link] is the purpose of the res folder in an Android project?

Answer: The res folder holds resources such as layout files, strings, images, and other
external elements used in the application.

[Link] do you define a layout in Android?

Answer: Layouts in Android are defined using XML files. Each component in the UI is
represented by an XML element and attributes define its properties.

[Link] is the [Link] file?

Answer: The [Link] file provides essential information about the app to the
Android system, such as the app's components, permissions, and metadata.

[Link] is the role of a Button in an Android app?

Answer: A Button is a UI component that can be clicked to perform an action, such as


submitting a form or navigating to another screen.
[Link] do you display a message to the user in Android?

Answer: You can display a message using a Toast, Snackbar, or AlertDialog. For example, to
sh
Code-Based Questions for MAD lab

1. How do you declare a TextView in an XML layout file?

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, World!" />

2. How do you find a view by its ID in an Activity?

java code

TextView textView = findViewById([Link]);

3. How do you set an OnClickListener for a Button in Java?

java code

Button button = findViewById([Link]);


[Link](new [Link]() {
@Override
public void onClick(View v) {
// Code to execute when button is clicked
}
});

[Link] do you start a new Activity using an Intent?

java code

Intent intent = new Intent([Link], [Link]);


startActivity(intent);

[Link] do you pass data from one Activity to another using an Intent?

java code

Intent intent = new Intent([Link], [Link]);


[Link]("key", "value");
startActivity(intent);

[Link] do you retrieve data from an Intent in the receiving Activity?

java code

Intent intent = getIntent();


String value = [Link]("key");

[Link] do you create a simple AlertDialog in Android?

java code
new [Link](this)
.setTitle("Alert")
.setMessage("This is an alert message")
.setPositiveButton([Link], new [Link]() {
public void onClick(DialogInterface dialog, int which) {
// Continue with action
}
})
.setNegativeButton([Link], null)
.setIcon([Link].ic_dialog_alert)
.show();

[Link] do you read a string resource in Java?

java code

String myString = getResources().getString([Link].my_string);

[Link] do you define a string resource in XML?


Answer:
xml

<resources>
<string name="my_string">Hello, World!</string>

[Link] do you handle runtime permissions in Android (e.g., for accessing the camera)?
Answer:
java code

if ([Link](this, [Link])
!= PackageManager.PERMISSION_GRANTED) {
[Link](this,
new String[]{[Link]},
MY_PERMISSIONS_REQUEST_CAMERA);
}

[Link] do you display an image from the drawable resources in an ImageView?

java code

ImageView imageView = findViewById([Link]);


[Link]([Link].my_image);

[Link] do you create a custom Toast message in Android?

java vode

Toast toast = [Link](getApplicationContext(), "Custom Toast",


Toast.LENGTH_SHORT);
[Link]([Link], 0, 0);
[Link]();

[Link] do you handle click events for items in a ListView?


java code

ListView listView = findViewById([Link]);


[Link](new [Link]() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Code to handle item click
}
});
ow a Toast:

[Link](getApplicationContext(), "Hello, World!",


Toast.LENGTH_SHORT).show();

You might also like