A developer wants to start playing a song using media player…
A developer wants to start playing a song using media player when the user opens a specific activity (built with API 35), but when the user navigates away from the activity (either by pressing the back button or by switching to another app), the media player should be stopped to avoid draining the device’s resources. Which activity Lifecycle method would be an ideal place to stop media player and release resources used by a Media Player if the user leaves the activity?
Read DetailsA mobile developer wants to develop an app with two Activiti…
A mobile developer wants to develop an app with two Activities (FirstActivity and SecondActivity). There is a button in the first activity. When the button is clicked, the second activity is launched using the following code: val intent =Intent(this, SecondActivity::class.java) startActivity(intent)In the second activity, there is a button to go back to the first activity. The developer uses a very similar code in onClick event of this button to go back to the first activity. val intent =Intent(this, FirstActivity::class.java) startActivity(intent)What are the advantages or disadvantages of this implementation? If this implementation is not ideal, how would you accomplish described functionality above? (Describe at a high level, actual code is not necessary)
Read Details