Weekend Sale Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: xmas50

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

In Android 8.0, API level 26, some APIs regarding notification behaviors were moved from Notification to NotificationChannel. For example, what should we use instead of NotificationCompat.Builder.setPriority() for Android 8.0 and higher?

A.

NotificationChannel.setPriority()

B.

NotificationChannel.setImportance()

C.

NotificationCompat.Builder.setImportance()

When using an ImageView, ImageButton, CheckBox, or other View that conveys information graphically. What attribute to use to provide a content label for that View?

A.

android:contentDescription

B.

android:hint

C.

android:labelFor

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

android:title="@string/pref_notification_title" android:summary="@string/pref_notification_summary" android:defaultValue="@bool/pref_notification_default_value" app:iconSpaceReserved="false"/>

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

A.

boolean isNotificationOn = PreferenceManager.getDefaultSharedPreferences(getContext ()).getBoolean(

getContext().getString(R.string.pref_notification_key), getContext().getResources().getBoolean(R.bool.pref_notification_default_value)

);

B.

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

getContext().getString(R.string.pref_notification_default_value), getContext().getString(R.string.pref_notification_key)

);

C.

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

getContext().getResources().getBoolean(R.bool.pref_notification_default_value), getContext().getString(R.string.pref_notification_key)

);

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?

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.

What do you want from Room when you create a DAO method and annotate it with @Update?

Example:

@Dao

public interface MyDao {

@Update

public void updateUsers(User... users);

}

A.

Room generates an implementation that inserts all parameters into the database in a single transaction.

B.

Room modifies a set of entities, given as parameters, in the database. It uses a query that matches against the primary key of each entity.

C.

Room removes a set of entities, given as parameters, from the database. It uses the primary keys to find the entities to delete.

What method should we use with Notification.Builder to supply a PendingIntent to be sent when the notification is clicked?

A.

setContentInfo

B.

setContentIntent

C.

setDeleteIntent

Move the major components of the Android platform to correct places in diagram.

For example, we have a BufferedReader reader, associated with the json file through

InputStreamReader. To get a file data we can do this:

A.

String line; try {

while ((line = reader.readLine()) != null) { builder.append(line);

}

JSONObject json = new JSONObject(builder.toString());

return json;

} catch (IOException | JSONException exception) {

exception.printStackTrace();

}

B.

JSONObject line; try {

while ((line = reader.readJSONObject ()) != null) { builder.append(line);

}

JSONObject json = new JSONObject(builder.toString());

return json;

} catch (IOException | JSONException exception) {

exception.printStackTrace();

}

C.

String line; try {

while ((line = reader.readLine()) != null) { builder.append(line);

}

JSONObject json = new JSONObject(builder.toString());

return json;

} catch (RuntimeException|ArrayIndexOutOfBoundsException exception) {

exception.printStackTrace();

}

In general, you should send an AccessibilityEvent whenever the content of your custom view changes. For example, if you are implementing a custom slider bar that allows a user to select a numeric value by pressing the left or right arrows, your custom view should emit an event of type TYPE_VIEW_TEXT_CHANGED whenever the slider value changes. Which one of the following sample codes demonstrates the use of the sendAccessibilityEvent() method to report this event.

A.

@Override

public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {

boolean completed = super.dispatchPopulateAccessibilityEvent(event);

CharSequence text = getText();

if (!TextUtils.isEmpty(text)) {

event.getText().add(text);

return true;

}

return completed;

}

B.

@Override

public boolean onKeyUp (int keyCode, KeyEvent event) {

if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {

currentValue--;

sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED);

return true;

}

...

}

C.

@Override

public boolean onKeyUp (int keyCode, KeyEvent event) {

if (keyCode == KeyEvent.KEYCODE_ENTER) {

currentValue--;

sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CONTEXT_CLICKED);

return true;

}

...

}

In our TeaViewModel class, that extends ViewModel, we have such method:

public LiveData getTea() { return mTea;

}

An observer in our Activity (type of mViewModel variable in example is TeaViewModel) is set in this way:

mViewModel.getTea().observe(this, this::displayTea);

What will be a correct displayTea method definition?

A.

private void displayTea()

B.

private void displayTea(Tea tea)

C.

private void displayTea(LiveData)

D.

private void displayTea(LiveData)