Adk Ans

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Q. Intent type with code .

1. Implicit Intent
Implicit Intent doesn’t specify the component. In such a case, intent provides
information on available components provided by the system that is to be invoked.
For example, you may write the following code to view the webpage.

val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://www.example.com"))

startActivity(intent)

2. Explicit Intent
Explicit Intent specifies the component. In such a case, intent provides the
external class to be invoked.

val intent = Intent(this, SecondActivity::class.java)

startActivity(intent)

Q . Android Project folder Structure/ project window


directory structure
The android project contains different types of app modules, source code files, and resource files.
We will explore all the folders and files in the android app.
Manifests Folder
Java Folder
res (Resources) Folder

Drawable Folder
Layout Folder
Mipmap Folder
Values Folder
Gradle Scripts
Manifests Folder
. This file contains information about our application such as the Android version, metadata, states
package for Kotlin file, and other application components.
Java folder
The Java folder contains all the java and Kotlin source code (.java) files that we create during the
app development, including other Test files.

Resource (res) folder


The resource folder is the most important folder because it contains all the non-code sources like
images, XML layouts, and UI strings for our android application.
res/drawable folder
It contains the different types of images used for the development of the application. We
need to add all the images in a drawable folder for the application development.

res/layout folder
The layout folder contains all XML layout files which we used to define the user interface
of our application. It contains the activity_main.xml file.

res/mipmap folder
This folder contains launcher.xml files to define icons that are used to show on the home screen. It
contains different density types of icons depending upon the size of the device such as hdpi, mdpi,
xhdpi.
res/values folder
Values folder contains a number of XML files like strings, dimensions, colors, and style
definitions. One of the most important files is the strings.xml file which contains the
resources.

Gradle Scripts folder


Gradle means automated build system and it contains a number of files that are used to define a
build configuration that can be applied to all modules in our application.

Q . Login page
<!-- activity_login.xml -->

<LinearLayout

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical"

android:padding="16dp">

<EditText

android:id="@+id/etEmail"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="Email" />

<EditText

android:id="@+id/etPassword"

android:layout_width="match_parent"

android:layout_height="wrap_content"
android:hint="Password"

android:inputType="textPassword" />

<Button

android:id="@+id/btnLogin"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="Login" />

<Button

android:id="@+id/btnCancel"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="Cancel " />

</LinearLayout>
Q . Android Activity Lifecycle methods

7 lifecycle methods(callbacks) of android activity.

Method Description

onCreate called when activity is first created.

onStart called when activity is becoming visible to the user.

onResume called when activity will start interacting with the user.

onPause called when activity is not visible to the user.

onStop called when activity is no longer visible to the user.

onRestart called after your activity is stopped, prior to start.

onDestroy called before the activity is destroyed.


Q. all layout with code in android development with Kotlin.
In Android development using Kotlin, layouts define the structure of the UI for
an activity or fragment. There
are several layout types you can use, depending on how you want to arrange the
views. Below is a description
of each layout, with example code.
1. LinearLayout
LinearLayout aligns all children in a single direction, either vertically or
horizontally.
Example:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
</LinearLayout>
2. RelativeLayout
RelativeLayout enables you to specify the position of child views relative to each
other or relative to the
parent.
Example:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
</RelativeLayout>
3. ConstraintLayout
ConstraintLayout is more flexible and powerful. It lets you define constraints
between views to position them
relative to each other or to the parent.
Example:
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>
4. TableLayout
TableLayout organizes views into rows and columns. Each row is defined with a
TableRow.Example:
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
</TableLayout>

You might also like