• 20 hours
  • Easy

Free online content available in this course.

course.header.alt.is_video

course.header.alt.is_certifying

Got it!

Last updated on 12/21/23

Test Your Knowledge

Evaluated skills

  • Optimize your Android app
  • Question 1

    What is the purpose of the second parameter (  requestCode  ) in the  startActivityForResult  method (Intent, int)?

    • It prevents problems with other applications using the same code.

    • It links up with the requestCode of the Activity in Manifest.

    • It identifies the request and helps the receiving Activity determine which result corresponds to which request.

    • It’s the Intent security keyit checks that it hasn’t been infected.

  • Question 2

    You want to launch a new Activity with  startActivityForResult()  . Which method should you override in the calling Activity to retrieve a result when the second Activity closes?

    • In the  onCreate()  method, you retrieve the result with the  getIntent().getResult()  method.

    • In the  onActivityResult()  method, you retrieve the information from the Intent passed as a parameter.

    • You retrieve the data using the  getIntent().getExtras()  method in any method of the life cycle.

    • In the  onSavedInstanceState()  method, the Bundle passed as a parameter allows you to retrieve the information of the closed Activity.

  • Question 3

    Which “key-value” type data persistence tool can you use so the user does not have to re-enter their name every time the app launches?

    • You can use a relational database to store the name as a String.

    • You can use the Intent of the Activity: it saves the name in between app launches.

    • You can use  SharedPreferences  to persist a String: it can be stored and retrieved with a constant key.

    • You can use a static variable, which persists the name in between app launches.

Ever considered an OpenClassrooms diploma?
  • Up to 100% of your training program funded
  • Flexible start date
  • Career-focused projects
  • Individual mentoring
Find the training program and funding option that suits you best