Weekend Sale Special - Limited Time 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: top65certs

Newly Released Google Associate-Android-Developer Exam PDF

Google Developers Certification - Associate Android Developer (Kotlin and Java Exam) Questions and Answers

Question 5

As an example. In an Activity we have our TimerViewModel object (extended ViewModel), named mTimerViewModel. mTimerViewModel.getTimer() method returns a LiveData value. What can be a correct way to set an observer to change UI in case if data was changed?

Options:

A.

mTimerViewModel.getTimer().getValue().toString().observe(new Observer() {

@Override

public void onChanged(Long aLong) {

callAnyChangeUIMethodHere(aLong)

}

});

B.

mTimerViewModel.getTimer().observe(this, new Observer() {

@Override

public void onChanged(Long aLong) {

callAnyChangeUIMethodHere(aLong)

}

});

C.

mTimerViewModel.observe(new Observer() {

@Override

public void onChanged(Long aLong) {

callAnyChangeUIMethodHere(aLong)

}

});

Question 6

If no any folder like res/anim-, res/drawable-, res/layout-, res/raw-

, res/xml- exist in the project. Which folders are required in the project anyway? (Choose two.)

Options:

A.

res/anim/

B.

res/drawable/

C.

res/layout/

D.

res/raw/

E.

res/xml/

Question 7

For example, suppose that in a XML file (res/menu/menu_main.xml as an example), where menu items are described, we have such item:

...

android:id="@+id/action_settings"

android:orderInCategory="100"

android:title="@string/menu_action_settings"

app:showAsAction="never" />

...

Attribute “app:showAsAction” shows when and how this item should appear as an action item in the app bar. What value “never” in this attribute means?

Options:

A.

Only place this item in the app bar if there is room for it. If there is not room for all the items marked by this value, the items with the lowest orderInCategory values are displayed as actions, and the remaining items are displayed in the overflow menu.

B.

Also include the title text (defined by android:title) with the action item. You can include this value along with one of the others as a flag set, by separating them with a pipe.

C.

Never place this item in the app bar. Instead, list the item in the app bar's overflow menu.

D.

Always place this item in the app bar. Avoid using this unless it's critical that the item always appear in the action bar. Setting multiple items to always appear as action items can result in them overlapping with other UI in the app bar.

E.

The action view associated with this action item (as declared by android:actionLayout or android:actionViewClass) is collapsible.

Question 8

For example, our preferences.xml file was added by addPreferencesFromResource (R.xml.preferences). Our preferences.xml file contains such item:

android:title="@string/pref_sort_title" android:summary="@string/pref_sort_summary" android:dialogTitle="@string/pref_sort_dialog_title" android:entries="@array/sort_oder" android:entryValues="@array/sort_oder_value" android:defaultValue="@string/pref_default_sort_value" app:iconSpaceReserved="false" />

In our Fragment, we can dynamically get current notification preference value in this way:

Options:

A.

String sortBy = PreferenceManager.getDefaultSharedPreferences(getContext ()).getString(

getContext().getString(R.string.pref_sort_key), getContext().getResources().getBoolean(R.bool.pref_default_sort_value)

);

B.

String sortBy = PreferenceManager.getSharedPreferences(getContext()).getString( getContext().getString(R.string.pref_default_sort_value), getContext().getString(R.string.pref_sort_key)

);

C.

boolean sortBy = PreferenceManager.getSharedPreferences(getContext()).getBoolean (

getContext().getResources().getBoolean(R.bool.pref_default_sort_value), getContext().getString(R.string.pref_sort_key)

);

D.

String sortBy = PreferenceManager.getDefaultSharedPreferences(getContext ()).getString(

getContext().getString(R.string.pref_sort_key), getContext().getString(R.string.pref_default_sort_value)

)