Android Problem Statement 2
Android Problem Statement 2
<EditText
android:id="@+id/et1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="Enter your text here"
android:inputType="text"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_margin="16dp"
app:layout_constraintHorizontal_bias="0.5" />
<Button
android:id="@+id/bt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit"
app:layout_constraintTop_toBottomOf="@+id/et1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="16dp" />
<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your input will appear here"
android:textSize="18sp"
android:padding="16dp"
app:layout_constraintTop_toBottomOf="@+id/bt1"
app:layout_constraintStart_toStartOf="parent"
Ritesh Rawat 22151876 BCA 5TH SEC-D
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="16dp" />
</[Link]>
Java Code:
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
EditText e1;
Button b1;
TextView t1;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
Ritesh Rawat 22151876 BCA 5TH SEC-D
e1 = findViewById([Link].et1);
b1 = findViewById([Link].bt1);
t1 = findViewById([Link].tv1);
[Link](new [Link]() {
@Override
public void onClick(View v) {
Output:
Ritesh Rawat 22151876 BCA 5TH SEC-D
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<EditText
android:id="@+id/et1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:layout_marginTop="388dp"
android:hint="Enter a number"
android:inputType="number"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/bt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="52dp"
android:text="Check Prime"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/et1" />
<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
app:layout_constraintTop_toBottomOf="@+id/bt1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="16dp" />
</[Link]>
Ritesh Rawat 22151876 BCA 5TH SEC-D
Java Code:
package [Link].myapplication1;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
EditText e1;
Button b1;
TextView t1;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
e1 = findViewById([Link].et1);
b1 = findViewById([Link].bt1);
t1 = findViewById([Link].tv1);
[Link](new [Link]() {
public void onClick(View v) {
String input = [Link]().toString();
if (![Link]()) {
int number = [Link](input);
if (isPrime(number)) {
[Link](number + " is a prime number.");
} else {
[Link](number + " is not a prime number.");
}
Ritesh Rawat 22151876 BCA 5TH SEC-D
} else {
[Link]("Please enter a valid number.");
}
}
});
}
Output:
Ritesh Rawat 22151876 BCA 5TH SEC-D
<EditText
android:id="@+id/et1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="Enter text"
android:layout_margin="16dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:inputType="text" />
<Button
android:id="@+id/bt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Convert to Uppercase"
app:layout_constraintTop_toBottomOf="@+id/et1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="16dp" />
<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
app:layout_constraintTop_toBottomOf="@+id/bt1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="16dp"
android:textSize="18sp" />
</[Link]>
Java Code:
Ritesh Rawat 22151876 BCA 5TH SEC-D
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
EditText e1;
Button b1;
TextView t1;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
e1 = findViewById([Link].et1);
b1 = findViewById([Link].bt1);
t1 = findViewById([Link].tv1);
[Link](new [Link]() {
@Override
public void onClick(View v) {
String userInput = [Link]().toString();
String upperCaseText = [Link]();
[Link](upperCaseText);
}
});
}}
Output:
Ritesh Rawat 22151876 BCA 5TH SEC-D
<EditText
android:id="@+id/et1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="Enter a string"
android:layout_margin="16dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:inputType="text" />
<Button
android:id="@+id/bt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Count"
app:layout_constraintTop_toBottomOf="@+id/et1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="16dp" />
<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Vowels: "
app:layout_constraintTop_toBottomOf="@+id/bt1"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
android:textSize="16sp" />
<TextView
android:id="@+id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Consonants: "
Ritesh Rawat 22151876 BCA 5TH SEC-D
app:layout_constraintTop_toBottomOf="@+id/tv1"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
android:textSize="16sp" />
<TextView
android:id="@+id/tv3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Characters: "
app:layout_constraintTop_toBottomOf="@+id/tv2"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
android:textSize="16sp" />
</[Link]>
Java Code:
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
Ritesh Rawat 22151876 BCA 5TH SEC-D
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
EditText e1;
Button b1;
TextView t1, t2, t3;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
e1 = findViewById([Link].et1);
b1 = findViewById([Link].bt1);
t1 = findViewById([Link].tv1);
t2 = findViewById([Link].tv2);
t3 = findViewById([Link].tv3);
[Link](new [Link]() {
public void onClick(View v) {
});
}
boolean isVowel(char c) {
return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
}
}
Output:
Ritesh Rawat 22151876 BCA 5TH SEC-D
<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text View Color"
android:textSize="18sp"
android:layout_marginTop="32dp"
android:padding="16dp"
android:background="@color/design_default_color_primary"
android:textColor="@android:color/white"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<Button
android:id="@+id/bt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Change Color"
app:layout_constraintTop_toBottomOf="@+id/tv1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="16dp" />
</[Link]>
Java Code:
package [Link];
import [Link];
import [Link];
import [Link];
Ritesh Rawat 22151876 BCA 5TH SEC-D
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
TextView t1;
Button b1;
Random r1;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
t1 = findViewById([Link].tv1);
b1 = findViewById([Link].bt1);
r1 = new Random();
[Link](new [Link]() {
@Override
public void onClick(View v) {
int color = getRandomColor();
[Link](color);
}
});
}
int getRandomColor() {
Output:
Ritesh Rawat 22151876 BCA 5TH SEC-D
<Button
android:id="@+id/bt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Change Background"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
</[Link]>
Java Code:
package [Link];
import [Link];
import [Link];
Ritesh Rawat 22151876 BCA 5TH SEC-D
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
ConstraintLayout c1;
Button b1;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
c1 = findViewById([Link].cl1);
b1 = findViewById([Link].bt1);
[Link](new [Link]() {
public void onClick(View v) {
[Link]([Link].a2);
}
});
}
}
Output:
Ritesh Rawat 22151876 BCA 5TH SEC-D
<View
android:id="@+id/vw1"
android:layout_width="200dp"
android:layout_height="200dp"
android:background="#FFCCBC"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintVertical_bias="0.4" />
<Button
android:id="@+id/bt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Change Color"
app:layout_constraintTop_toBottomOf="@+id/vw1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintVertical_bias="0.6"
android:layout_marginTop="16dp" />
</[Link]>
Java Code:
package [Link];
import [Link];
import [Link];
Ritesh Rawat 22151876 BCA 5TH SEC-D
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
View v1;
Button b1;
Random r1;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
v1 = findViewById([Link].vw1);
b1 = findViewById([Link].bt1);
[Link](new [Link]() {
@Override
public void onClick(View v) {
int getRandomColor() {
Output:
Ritesh Rawat 22151876 BCA 5TH SEC-D
<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Change text color!"
android:textSize="24sp"
android:gravity="center"
android:padding="16dp"
android:textColor="#000000"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="32dp"/>
<Button
android:id="@+id/bt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Change Text Color"
app:layout_constraintTop_toBottomOf="@id/tv1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="16dp"/>
</[Link]>
Java Code:
package [Link];
import [Link];
import [Link];
import [Link];
Ritesh Rawat 22151876 BCA 5TH SEC-D
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
TextView t1;
Button b1;
@Override
protected void onCreate (Bundle savedInstanceState){
[Link](savedInstanceState);
setContentView([Link].activity_main);
t1 = findViewById([Link].tv1);
b1 = findViewById([Link].bt1);
[Link](new [Link]() {
public void onClick(View v) {
Output:
Ritesh Rawat 22151876 BCA 5TH SEC-D
<EditText
android:id="@+id/et1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="Enter First Number"
android:inputType="numberDecimal"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="32dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp" />
<EditText
android:id="@+id/et2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="Enter Second Number"
android:inputType="numberDecimal"
app:layout_constraintTop_toBottomOf="@+id/et1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp" />
<Button
android:id="@+id/bt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add"
app:layout_constraintTop_toBottomOf="@+id/et2"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp" />
<Button
Ritesh Rawat 22151876 BCA 5TH SEC-D
android:id="@+id/bt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Subtract"
app:layout_constraintTop_toBottomOf="@+id/et2"
app:layout_constraintStart_toEndOf="@id/bt1"
android:layout_marginTop="16dp"
android:layout_marginStart="8dp" />
<Button
android:id="@+id/bt3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Multiply"
app:layout_constraintTop_toBottomOf="@+id/et2"
app:layout_constraintStart_toEndOf="@id/bt2"
android:layout_marginTop="16dp"
android:layout_marginStart="8dp" />
<Button
android:id="@+id/bt4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Divide"
app:layout_constraintTop_toBottomOf="@+id/et2"
app:layout_constraintStart_toEndOf="@id/bt3"
android:layout_marginTop="16dp"
android:layout_marginStart="8dp" />
<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Result: "
android:textSize="18sp"
app:layout_constraintTop_toBottomOf="@id/bt1"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginTop="32dp"
android:layout_marginStart="16dp" />
</[Link]>
Ritesh Rawat 22151876 BCA 5TH SEC-D
Java Code:
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
Ritesh Rawat 22151876 BCA 5TH SEC-D
import [Link];
import [Link];
import [Link];
EditText e1 , e2;
TextView t1;
Button b1, b2, b3, b4;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
e1 = findViewById([Link].et1);
e2 = findViewById([Link].et2);
t1 = findViewById([Link].tv1);
b1 = findViewById([Link].bt1);
b2 = findViewById([Link].bt2);
b3 = findViewById([Link].bt3);
b4 = findViewById([Link].bt4);
[Link](new [Link]() {
@Override
public void onClick(View v) {
performOperation("+");
}
});
[Link](new [Link]() {
@Override
public void onClick(View v) {
performOperation("-");
}
});
[Link](new [Link]() {
@Override
public void onClick(View v) {
performOperation("*");
}
});
[Link](new [Link]() {
Ritesh Rawat 22151876 BCA 5TH SEC-D
@Override
public void onClick(View v) {
performOperation("/");
}
});
}
switch (operation) {
case "+":
result = num1 + num2;
break;
case "-":
result = num1 - num2;
break;
case "*":
result = num1 * num2;
break;
case "/":
if (num2 != 0) {
result = num1 / num2;
} else {
[Link]("Cannot divide by 0");
return;
}
break;
}
[Link]("Result: " + result);
} else {
[Link]("Please enter both numbers");
}
}
}
Ritesh Rawat 22151876 BCA 5TH SEC-D
Output:
Ritesh Rawat 22151876 BCA 5TH SEC-D
XML Code:
<?xml version="1.0" encoding="utf-8"?>
<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<EditText
android:id="@+id/et1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="Enter your name"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="32dp"
android:padding="16dp" />
<EditText
android:id="@+id/et2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="Enter your age"
android:inputType="number"
app:layout_constraintTop_toBottomOf="@id/et1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="16dp"
android:padding="16dp" />
<Button
android:id="@+id/bt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Validate"
app:layout_constraintTop_toBottomOf="@id/et2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="32dp"/>
Ritesh Rawat 22151876 BCA 5TH SEC-D
<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="18sp"
app:layout_constraintTop_toBottomOf="@id/bt1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="16dp"
android:padding="16dp"/>
</[Link]>
Java Code:
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
Ritesh Rawat 22151876 BCA 5TH SEC-D
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
EditText e1;
EditText e2;
Button b1;
TextView t1;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
e1 = findViewById([Link].et1);
e2 = findViewById([Link].et2);
b1 = findViewById([Link].bt1);
t1 = findViewById([Link].tv1);
[Link](new [Link]() {
@Override
public void onClick(View v) {
validateInput();
}
});
}
if ([Link]() || [Link]()) {
[Link](this, "No field should be left blank.",
Toast.LENGTH_SHORT).show();
return;
}
if () {
[Link](this, "Name should contain only alphabets and
underscores.", Toast.LENGTH_SHORT).show();
return;
Ritesh Rawat 22151876 BCA 5TH SEC-D
int age;
try {
age = [Link](ageString);
} catch (NumberFormatException e) {
[Link](this, "Please enter a valid age.",
Toast.LENGTH_SHORT).show();
return;
}
Output:
Ritesh Rawat 22151876 BCA 5TH SEC-D
XML Code:
<?xml version="1.0" encoding="utf-8"?>
<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<EditText
android:id="@+id/et1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="Enter alphanumeric input"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="32dp"
android:padding="16dp" />
<Button
android:id="@+id/bt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Check Armstrong"
app:layout_constraintTop_toBottomOf="@id/et1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="16dp"/>
<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="18sp"
app:layout_constraintTop_toBottomOf="@id/bt1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="16dp"
android:padding="16dp"/>
</[Link]>
Java Code:
Ritesh Rawat 22151876 BCA 5TH SEC-D
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
EditText e1;
Button b1;
TextView t1;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
e1 = findViewById([Link].et1);
b1 = findViewById([Link].bt1);
t1 = findViewById([Link].tv1);
[Link](new [Link]() {
@Override
public void onClick(View v) {
checkArmstrong();
}
});
}
int sum = 0;
int digitCount = 0;
Ritesh Rawat 22151876 BCA 5TH SEC-D
if (digitCount == 0) {
[Link]("No digits found in the input.");
return;
}
if (armstrongSum == sum) {
[Link](sum + " is an Armstrong number.");
} else {
[Link](sum + " is not an Armstrong number.");
}
}
}
Output:
Ritesh Rawat 22151876 BCA 5TH SEC-D
XML Code:
Ritesh Rawat 22151876 BCA 5TH SEC-D
<TextView
android:id="@+id/tv1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Activity Lifecycle State"
android:textSize="18sp"
android:padding="16dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="32dp" />
<Button
android:id="@+id/bt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Restart Activity"
app:layout_constraintTop_toBottomOf="@id/tv1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="16dp" />
</[Link]>
Java Code:
package [Link];
import [Link];
Ritesh Rawat 22151876 BCA 5TH SEC-D
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
t1 = findViewById([Link].tv1);
logAndDisplay("\nonCreate");
@Override
protected void onStart() {
[Link]();
logAndDisplay("onStart");
}
@Override
protected void onResume() {
[Link]();
logAndDisplay("onResume");
}
@Override
protected void onPause() {
[Link]();
logAndDisplay("onPause");
Ritesh Rawat 22151876 BCA 5TH SEC-D
@Override
protected void onStop() {
[Link]();
logAndDisplay("onStop");
}
@Override
protected void onDestroy() {
[Link]();
logAndDisplay("onDestroy");
}
@Override
protected void onRestart() {
[Link]();
logAndDisplay("onRestart");
}
Output:
Ritesh Rawat 22151876 BCA 5TH SEC-D