Hi all,
You can reach the Turkish version of this post from here and the first post from here.
After reviewing codelabs, maybe the first post was meaningful but for the following posts, I think only the code samples will be enough. If you noticed my blog post while preparing to codelabs and have questions, please do not hesitate to ask. The the projects below include samples for Unit 1.
Projects:
Android fundamentals 01.2 Part A: Your first interactive UI
Android fundamentals 01.2 Part B: The layout editor
Android fundamentals 01.3: Text and scrolling views
Android fundamentals 01.4: Learn to help yourself
Android fundamentals 02.1: Activities and intents
Android fundamentals 02.2: Activity lifecycle and state
Android fundamentals 02.3: Implicit intents
Android fundamentals 03.1: The debugger
- I didn’t re-coded the sample because only logging was reviewed with using an existing project.
Android fundamentals 03.2: Unit tests
- I didn’t re-coded the sample because only unit test was talked with using an existing project.
Android fundamentals 03.3: Support libraries
-
Answer the questions:
Android fundamentals 01.2 Part B: The layout editor
QUESTİON 1
Which two layout constraint attributes on the Zero
Buttonposition it vertically equal distance between the other twoButtonelements? (Pick 2 answers.)app:layout_constraintBottom_toTopOf="@+id/button_count"android:layout_marginBottom="8dp"android:layout_marginStart="16dp"app:layout_constraintTop_toBottomOf="@+id/button_toast"android:layout_marginTop="8dp"
QUESTİON 2
Which layout constraint attribute on the Zero
Buttonpositions it horizontally in alignment with the other twoButtonelements?app:layout_constraintLeft_toLeftOf="parent"app:layout_constraintBottom_toTopOf="@+id/button_count"android:layout_marginBottom="8dp"app:layout_constraintTop_toBottomOf="@+id/button_toast"
QUESTİON 3
What is the correct signature for a method used with the
android:onClickXML attribute?public void callMethod()public void callMethod(View view)private void callMethod(View view)public boolean callMethod(View view)
QUESTİON 4
The click handler for the Count
Buttonstarts with the following method signature:public void countUp(View view)Which of the following techniques is more efficient to use within this handler to change the
Buttonelement’s background color? Choose one:- Use
findViewByIdto find the CountButton. Assign the result to aViewvariable, and then usesetBackgroundColor(). - Use the
viewparameter that is passed to the click handler withsetBackgroundColor():view.setBackgroundColor()
Android fundamentals 01.3: Text and scrolling views
QUESTİON 1
How many views can you use within a
ScrollView? Choose one:- One view only
- One view or one view group
- As many as you need
QUESTİON 2
Which XML attribute do you use in a
LinearLayoutto show views side by side? Choose one:android:orientation="horizontal"android:orientation="vertical"android:layout_width="wrap_content"
QUESTİON 3
Which XML attribute do you use to define the width of the
LinearLayoutinside the scrolling view? Choose one:android:layout_width="wrap_content"android:layout_width="match_parent"android:layout_width="200dp"
01.4: Learn to help yourself
QUESTİON 1
Within an Android Studio project, what menu command can you use to open the list of sample apps? Choose one:
- File > Open
- File > New > Import Sample
- File > New > Import Module
- File > New > Import Project
QUESTİON 2
Which buttons does the Basic Activity template provide as part of the UI? Choose two:
- Navigation buttons
- Options menu overflow button
- Floating action button
Buttonclass button with the text “Button”
QUESTİON 3
Which source of documentation is the official documentation for Android developers? Choose one:
- stackoverflow.com
- officialandroid.blogspot.com
- developer.android.com
- github.com
Android fundamentals 01.4: Learn to help yourself
QUESTİON 1
What changes are made when you add a second
Activityto your app by choosing File > New > Activity and anActivitytemplate? Choose one:- The second
Activityis added as a Java class. You still need to add the XML layout file. - The second
ActivityXML layout file is created and a Java class added. You still need to define the class signature. - The second
Activityis added as a Java class, the XML layout file is created, and theAndroidManifest.xmlfile is changed to declare a secondActivity. - The second
ActivityXML layout file is created, and theAndroidManifest.xmlfile is changed to declare a secondActivity.
QUESTİON 2
What happens if you remove the
android:parentActivityNameand the<meta-data>elements from the secondActivitydeclaration in theAndroidManifest.xmlfile? Choose one:- The second
Activityno longer appears when you try to start it with an explicitIntent. - The second
ActivityXML layout file is deleted. - The Back button no longer works in the second
Activityto send the user back to the mainActivity. - The Up button in the app bar no longer appears in the second
Activityto send the user back to the parentActivity.
QUESTİON 3
Which constructor method do you use to create a new explicit
Intent? Choose one:new Intent()new Intent(Context context, Class<?> class)new Intent(String action, Uri uri)new Intent(String action)
QUESTİON 4
In the HelloToast app homework, how do you add the current value of the count to the
Intent? Choose one:- As the
Intentdata - As the
IntentTEXT_REQUEST - As an
Intentaction - As an
Intentextra
QUESTİON 5
In the HelloToast app homework, how do you display the current count in the second “Hello”
Activity? Choose one:- Get the
Intentthat theActivitywas launched with. - Get the current count value out of the
Intent. - Update the
TextViewfor the count. - All of the above.
Android fundamentals 02.2: Activity lifecycle and state
QUESTİON 1
If you run the homework app before implementing
onSaveInstanceState(), what happens if you rotate the device? Choose one:- The
EditTextno longer contains the text you entered, but the counter is preserved. - The counter is reset to 0, and the
EditTextno longer contains the text you entered. - The counter is reset to 0, but the contents of the
EditTextis preserved. - The counter and the contents of the
EditTextare preserved.
QUESTİON 2
What
Activitylifecycle methods are called when a device-configuration change (such as rotation) occurs? Choose one:- Android immediately shuts down your
Activityby callingonStop(). Your code must restart theActivity. - Android shuts down your
Activityby callingonPause(),onStop(), andonDestroy(). Your code must restart theActivity. - Android shuts down your
Activityby callingonPause(),onStop(), andonDestroy(), and then starts it over again, callingonCreate(),onStart(), andonResume(). - Android immediately calls
onResume().
QUESTİON 3
When in the
Activitylifecycle isonSaveInstanceState()called? Choose one:onSaveInstanceState()is called before theonStop()method.onSaveInstanceState()is called before theonResume()method.onSaveInstanceState()is called before theonCreate()method.onSaveInstanceState()is called before theonDestroy()method.
QUESTİON 4
Which
Activitylifecycle methods are best to use for saving data before theActivityis finished or destroyed? Choose one:onPause()oronStop()onResume()oronCreate()onDestroy()onStart()oronRestart()
Android fundamentals 02.3: Implicit intents
QUESTİON 1
Which constructor method do you use to create an implicit
Intentto launch a camera app?new Intent()new Intent(Context context, Class<?> class)new Intent(String action, Uri uri)new Intent(String action)
QUESTİON 2
When you create an implicit
Intentobject, which of the following is true?- Don’t specify the specific
Activityor other component to launch. - Add an
Intentaction orIntentcategories (or both). - Resolve the
Intentwith the system before callingstartActivity()orstartActivityforResult(). - All of the above.
QUESTİON 3
Which
Intentaction do you use to take a picture with a camera app?Intent takePicture = new Intent(Intent.ACTION_VIEW);Intent takePicture = new Intent(Intent.ACTION_MAIN);Intent takePicture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);Intent takePicture = new Intent(Intent.ACTION_GET_CONTENT);
Android fundamentals 03.1: The debugger
QUESTİON 1
Run the SimpleCalc app without the debugger. Leave one or both of the
EditTextelements empty, and try any calculation. Why did the error occur?java.lang.NumberFormatException: empty StringW/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED- The app may be doing too much work on its main thread.
- The code cache capacity was increased to 128KB.
QUESTİON 2
Which function do you perform in the Debug pane in order to execute the current line where the breakpoint is, and then stop at the next line in the code? Choose one:
- Step Into
- Step Over
- Step Out
- Resume
QUESTİON 3
Which function do you perform in the Debug pane in order to jump to the execution of a method call from the current line where the breakpoint is? Choose one:
- Step Into
- Step Over
- Step Out
- Resume
Android fundamentals 03.2: Unit tests
QUESTİON 1
Which statement best describes a local unit test? Choose one:
- Tests that run on an Android-powered device or emulator and have access to the Android framework.
- Tests that enable you to write automated UI test methods.
- Tests that are compiled and run entirely on your local machine with the Java Virtual Machine (JVM).
QUESTİON 2
Source sets are collections of related code. In which source set are you likely to find unit tests? Choose one:
app/rescom.example.android.SimpleCalcTestcom.example.android.SimpleCalcTest (test)com.example.android.SimpleCalcTest (androidTest)
QUESTİON 3
Which annotation is used to mark a method as an actual test? Choose one:
@RunWith(JUnit4.class)@SmallTest@Before@Test
Android fundamentals 03.3: Support libraries
QUESTİON 1
Which class appears when you first Step Into the
ContextCompat.getColor()method? Choose one:MainActivityContextCompatAppCompatActivityContext
QUESTİON 2
In the class that appears, which statement is executed if the build version is API version 23 or newer? Choose one:
return context.getColor(id);return context.getResources().getColor(id);throw new IllegalArgumentException("permission is null");return mResources == null ? super.getResources() : mResources;
QUESTİON 3
If you change the
ContextCompat.getColor()method back to thegetColor()method, what will happen when you run the app? Choose one:- If your
minSdkVersionis 15, the wordgetColoris underlined in red in the code editor. Hover your pointer over it, and Android Studio reports “Call requires API 23 (current min is 15)”. - The app will run without error on emulators and devices using API 23 or newer.
- The app will crash when the user taps Change Color if the emulator or device is using API 17.
- All of the above.
References:
- https://codelabs.developers.google.com/codelabs/android-training-layout-editor-part-a/index.html?index=..%2F..android-training#0
- https://google-developer-training.github.io/android-developer-fundamentals-course-concepts-v2/unit-1-get-started/lesson-1-build-your-first-app/1-2-c-layouts-and-resources-for-the-ui/1-2-c-layouts-and-resources-for-the-ui.html
- https://docs.google.com/presentation/d/10ARO1cnG0E34igbyPZfyV2rr_skdHtHKMsnbvGoYUKY/edit
Leave a comment