You are on page 1of 4

A ASSIGNMENT-1 (Android Programming )

FILE SUBMITTED TO
GIAN JYOTI INSTITUTE OF MANAGEMENT
&
TECHNOLOGY
PHASE-2, MOHALI
AFFILIATED TO

PUNJAB TECHNICAL UNIVERSITY, JALANDHAR


FOR THE PARTIAL FULFILLMENT FOR QUALIFYING BCA DEGREE

SUBMITTED TO: SUBMITTED BY:


Ms. Jaspreet Kaur Narender Singh(2011237)
1. What are the components inside android SDK?
Ans. The components inside Android SDK are:
 Android Debug Bridge (ADB): a command-line tool that allows communication between a device or
emulator and a computer.
 Android Emulator: an emulator that allows developers to test their apps without a physical device.
 Android Asset Packaging Tool (AAPT): a tool that generates the .apk file for an Android app.
 Android Interface Definition Language (AIDL): a language used to define Android interfaces.
 Android Build Tool: a tool that compiles and packages Android apps.
 Android Support Library: a library that provides backward compatibility for newer Android features.
 Android System Image: an image that contains the Android operating system.
 Android Virtual Device (AVD) Manager: a tool that manages Android virtual devices.
 Android Studio: the official integrated development environment (IDE) for Android app development

2. List any five basic controls in android.


Ans. Five basic controls in Android are:
 TextView: used to display text on the screen.
 EditText: used to allow users to enter text.
 Button: used to trigger an action when clicked.
 ImageView: used to display images on the screen.
 CheckBox: used to allow users to select one or more options.

3. Show the syntax for button in XML.


Ans. The syntax for Button in XML is:
<Button
android:id="@+id/button_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button Text" />

4. Explain Java API Framework in android stack.


Ans. Java API Framework in Android Stack is a set of Java classes and interfaces that developers can use to
create Android apps. It includes packages such as java.lang, java.io, java.util, and more.

5. Explain in detail about android lifecycle events with a neat figure.


Ans.Android lifecycle events refer to the different stages an activity or fragment goes through during its
lifetime. The events include:
 onCreate(): called when the activity or fragment is created.
 onStart(): called when the activity or fragment is visible to the user.
 onResume(): called when the activity or fragment is in the foreground and the user can interact with it.
 onPause(): called when the activity or fragment loses focus but is still visible to the user.
 onStop(): called when the activity or fragment is no longer visible to the user.
 onDestroy(): called when the activity or fragment is destroyed.

Here's a diagram that shows the different Android lifecycle events: onCreate()
|
onStart()
|
onResume()
|
User interacts
|
onPause()
|
onStop()
|
onDestroy()

6. Explain any two types of drawable resource?


Ans.Two types of drawable resources in Android are:

 Bitmap drawables: used to display bitmap images.

 Vector drawables: used to display vector graphics that can be scaled without losing quality.

7. Explain the syntax of Shared Preferences.

Ans.The syntax for Shared Preferences is:


 To write data to Shared Preferences:
SharedPreferences.Editor editor = getSharedPreferences("my_preferences",MODE_PRIVATE).edit();
editor.putString("key", "value");editor.apply();
 To read data from Shared Preferences:
SharedPreferences preferences = getSharedPreferences("my_preferences", MODE_PRIVATE);
String value = preferences.getString("key", "default_value");

8. Discuss in detail about android application components


Ans. Android application components are building blocks that make up an Android app. The four types of
application components are:
 Activities: the user interface of the app.
 Services: used to perform background tasks without a user interface.
 Broadcast receivers: used to receive and handle system-wide broadcast messages.
 Content providers: used to manage shared data across different apps.

9. How to use spinners in android? Explain with an example

Ans. example of how to use spinners in Android:

Add a Spinner element to your XML layout:


<Spinner

android:id="@+id/spinner_id"

android:layout_width="match_parent"

android:layout_height="wrap_content"/>

10. Explain about notifications in android with an example program.

Ans.Notifications are a way for Android apps to display important information to the user outside of the app itself.
Here's an example program that shows how to create a simple notification in Android:
1. Create a NotificationChannel:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {


NotificationChannel channel = new NotificationChannel("channel_id", "Channel Name",
NotificationManager.IMPORTANCE_DEFAULT);
NotificationManager notificationManager = getSystemService(NotificationManager.class);
notificationManager.createNotificationChannel(channel);
}

This code creates a new notification channel with the ID "channel_id" and the name "Channel Name". This step is
required for Android 8.0 (API level 26) and higher.

2. Create a Notification
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "channel_id")
.setSmallIcon(R.drawable.notification_icon)
.setContentTitle("My Notification Title")
.setContentText("This is my notification text.")
.setPriority(NotificationCompat.PRIORITY_DEFAULT);

NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);


notificationManager.notify(0, builder.build());

You might also like