Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Developing Android applications that include multiple activities and fragments. Write an Android Application that demonstrates the activity life cycle and fragments lifecycle. The main activity

Developing Android applications that include multiple activities and fragments.

Write an Android Application that demonstrates the activity life cycle and fragments lifecycle. The main activity should have two fragments. The top fragment contains a list view control whose items are the names of two other activities, AIActivity and VRActivity. The bottom fragment uses a text view control to display the list of life cycle methods that take place when the main activity starts.

image text in transcribed

Use Toast class methods to display a quick message in fragments onCreateView and onStart methods.

Alternatively, use Bundle to pass information from the main activity to the bottom fragment:

//use Bundle to pass data to the fragment val args = Bundle() args.putString("onCreate", "onCreate of MainActivityExecuted") //create a fragment reference

val displayFragment = supportFragmentManager.findFragmentById( R.id.fragment_container_view_bottom) as BottomFragment displayFragment.arguments =args

Then, in onCreateView of the bottom fragment, you can use the following code to get the information from Bundle:

// get the data from Bundle val info = arguments?.getString("onCreate")

The AIActivity and ARActivity should each have a TextView control to display messages when onCreate, onStart, onStop, and onDestroy are executed.

Declare the String resources in strings.xml file.

Life Cycle Methods Demonstration AlActivity. ARActivity

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

More Books

Students also viewed these Databases questions

Question

Discuss the history of human resource management (HRM).

Answered: 1 week ago