ExamGecko
Home Home / Google / Associate Android Developer

Google Associate Android Developer Practice Test - Questions Answers, Page 7

Question list
Search
Search

List of questions

Search

Related questions











About queries in DAO classes. Room verifies the return value of the query such that if the name of the field in the returned object doesn't match the corresponding column names in the query response, Room alerts you in one of the following two ways: (Choose two.)

A.
It gives a warning if no field names match.
A.
It gives a warning if no field names match.
Answers
B.
It gives a warning if only some field names match.
B.
It gives a warning if only some field names match.
Answers
C.
It gives an error if no field names match.
C.
It gives an error if no field names match.
Answers
D.
It gives an error if only some field names match.
D.
It gives an error if only some field names match.
Answers
Suggested answer: B, C

Select four different types of app components. (Choose four.)

A.
Application
A.
Application
Answers
B.
Layouts
B.
Layouts
Answers
C.
Activities
C.
Activities
Answers
D.
Services
D.
Services
Answers
E.
AlarmManager
E.
AlarmManager
Answers
F.
WorkManager
F.
WorkManager
Answers
G.
Broadcast receivers
G.
Broadcast receivers
Answers
H.
Content providers
H.
Content providers
Answers
I.
Fragments
I.
Fragments
Answers
Suggested answer: C, D, G, H

What is a correct part of an Implicit Intent for sharing data implementation?

A.
Intent sendIntent = new Intent(this, UploadService.class) sendIntent.putExtra(Intent.EXTRA_TEXT, textMessage);
A.
Intent sendIntent = new Intent(this, UploadService.class) sendIntent.putExtra(Intent.EXTRA_TEXT, textMessage);
Answers
B.
Intent sendIntent = new Intent(); sendIntent.setType(Intent.ACTION_SEND);
B.
Intent sendIntent = new Intent(); sendIntent.setType(Intent.ACTION_SEND);
Answers
C.
Intent sendIntent = new Intent(this, UploadService.class) sendIntent.setData(Uri.parse(fileUrl));
C.
Intent sendIntent = new Intent(this, UploadService.class) sendIntent.setData(Uri.parse(fileUrl));
Answers
D.
Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND);
D.
Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND);
Answers
Suggested answer: D

Explanation:

Create the text message with a string

Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, textMessage); sendIntent.setType("text/plain");

Reference: https://developer.android.com/guide/components/fundamentals

By default, the notification's text content is truncated to fit one line. If you want your notification to be longer, for example, to create a larger text area, you can do it in this way:

A.
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID).setContentText("Much longer text that cannot fit one line...").setStyle(new NotificationCompat.BigTextStyle().bigText("Much longer text that cannot fit one line..."))
A.
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID).setContentText("Much longer text that cannot fit one line...").setStyle(new NotificationCompat.BigTextStyle().bigText("Much longer text that cannot fit one line..."))
Answers
B.
.
B.
.
Answers
C.
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID).setContentText("Much longer text that cannot fit one line...").setLongText("Much longer text that cannot fit one line..."))
C.
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID).setContentText("Much longer text that cannot fit one line...").setLongText("Much longer text that cannot fit one line..."))
Answers
D.
.
D.
.
Answers
E.
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID).setContentText("Much longer text that cannot fit one line...") .setTheme(android.R.style.Theme_LongText); ...
E.
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID).setContentText("Much longer text that cannot fit one line...") .setTheme(android.R.style.Theme_LongText); ...
Answers
Suggested answer: A

Explanation:

Reference:

https://developer.android.com/training/notify-user/build-notification

"workManager" is an instance of WorkManager. Select correct demonstration of WorkRequest cancellation:

A.
workManager.enqueue(new OneTimeWorkRequest.Builder(FooWorker.class).build());
A.
workManager.enqueue(new OneTimeWorkRequest.Builder(FooWorker.class).build());
Answers
B.
WorkRequest request = new OneTimeWorkRequest.Builder(FooWorker.class).build(); workManager.enqueue(request);LiveData<WorkInfo> status = workManager.getWorkInfoByIdLiveData(request.getId()); status.observe(...);
B.
WorkRequest request = new OneTimeWorkRequest.Builder(FooWorker.class).build(); workManager.enqueue(request);LiveData<WorkInfo> status = workManager.getWorkInfoByIdLiveData(request.getId()); status.observe(...);
Answers
C.
WorkRequest request = new OneTimeWorkRequest.Builder(FooWorker.class).build(); workManager.enqueue(request);workManager.cancelWorkById(request.getId());
C.
WorkRequest request = new OneTimeWorkRequest.Builder(FooWorker.class).build(); workManager.enqueue(request);workManager.cancelWorkById(request.getId());
Answers
D.
WorkRequest request1 = new OneTimeWorkRequest.Builder(FooWorker.class).build();WorkRequest request2 = new OneTimeWorkRequest.Builder(BarWorker.class).build(); WorkRequest request3 = new OneTimeWorkRequest.Builder(BazWorker.class).build(); workManager.beginWith(request1, request2).then(request3).enqueue();
D.
WorkRequest request1 = new OneTimeWorkRequest.Builder(FooWorker.class).build();WorkRequest request2 = new OneTimeWorkRequest.Builder(BarWorker.class).build(); WorkRequest request3 = new OneTimeWorkRequest.Builder(BazWorker.class).build(); workManager.beginWith(request1, request2).then(request3).enqueue();
Answers
E.
WorkRequest request = new OneTimeWorkRequest.Builder(FooWorker.class).build(); workManager.enqueue(request); workManager.cancelWork(request);
E.
WorkRequest request = new OneTimeWorkRequest.Builder(FooWorker.class).build(); workManager.enqueue(request); workManager.cancelWork(request);
Answers
Suggested answer: C

Explanation:

Videos:

Working with WorkManager, from the 2018 Android Dev Summit

WorkManager: Beyond the basics, from the 2019 Android Dev Summit

Reference: https://developer.android.com/reference/androidx/work/WorkManager?hl=en

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;}
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;}
Answers
B.
@Override public boolean onKeyUp (int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) { currentValue--;sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED); return true;}
B.
@Override public boolean onKeyUp (int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) { currentValue--;sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED); return true;}
Answers
C.
.}
C.
.}
Answers
D.
@Override public boolean onKeyUp (int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ENTER) { currentValue--;sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CONTEXT_CLICKED); return true;}
D.
@Override public boolean onKeyUp (int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ENTER) { currentValue--;sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CONTEXT_CLICKED); return true;}
Answers
E.
.}
E.
.}
Answers
Suggested answer: B

Explanation:

Reference:

https://developer.android.com/guide/topics/ui/accessibility/custom-views

The easiest way of adding menu items (to specify the options menu for an activity) is inflating an XML file into the Menu via MenuInflater. With menu_main.xml we can do it in this way:

A.
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_main, menu); return true;}
A.
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_main, menu); return true;}
Answers
B.
@Override public boolean onOptionsItemSelected(MenuItem item) { getMenuInflater().inflate(R.menu.menu_main, menu); returnsuper.onOptionsItemSelected(item); }
B.
@Override public boolean onOptionsItemSelected(MenuItem item) { getMenuInflater().inflate(R.menu.menu_main, menu); returnsuper.onOptionsItemSelected(item); }
Answers
C.
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.menu.menu_main); }
C.
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.menu.menu_main); }
Answers
Suggested answer: A

Explanation:

Reference:

https://developer.android.com/guide/topics/ui/menus

Android Tests. You can use the childSelector() method to nest multiple UiSelector instances. For example, the following code example shows how your test might specify a search to find the first ListView in the currently displayed UI, then search within that ListView to find a UI element with the text property Apps. What is the correct sample?

A.
UiObject appItem = device.findObject(new UiSelector().className(ListView.class).instance(1).childSelector(new UiSelector().text("Apps")));
A.
UiObject appItem = device.findObject(new UiSelector().className(ListView.class).instance(1).childSelector(new UiSelector().text("Apps")));
Answers
B.
UiObject appItem = device.findObject(new UiSelector().className("android.widget.ListView").instance(0).childSelector(new UiSelector().text("Apps")));
B.
UiObject appItem = device.findObject(new UiSelector().className("android.widget.ListView").instance(0).childSelector(new UiSelector().text("Apps")));
Answers
C.
UiObject appItem = device.findObject(new UiSelector().className("android.widget.ListView").instance(new UiSelector().text("Apps")));
C.
UiObject appItem = device.findObject(new UiSelector().className("android.widget.ListView").instance(new UiSelector().text("Apps")));
Answers
Suggested answer: B

The following code snippet shows an example of an Espresso test:

A.
@Rule public void greeterSaysHello() {onView(withId(R.id.name_field)).do(typeText("Steve")); onView(withId(R.id.greet_button)).do(click());onView(withText("Hello Steve!")).check(matches(isDisplayed())); }
A.
@Rule public void greeterSaysHello() {onView(withId(R.id.name_field)).do(typeText("Steve")); onView(withId(R.id.greet_button)).do(click());onView(withText("Hello Steve!")).check(matches(isDisplayed())); }
Answers
B.
@Test public void greeterSaysHello() {onView(withId(R.id.name_field)).perform(typeText("Steve")); onView(withId(R.id.greet_button)).perform(click());onView(withText("Hello Steve!")).check(matches(isDisplayed())); }
B.
@Test public void greeterSaysHello() {onView(withId(R.id.name_field)).perform(typeText("Steve")); onView(withId(R.id.greet_button)).perform(click());onView(withText("Hello Steve!")).check(matches(isDisplayed())); }
Answers
C.
@Test public void greeterSaysHello() {onView(withId(R.id.name_field)).do(typeText("Steve")); onView(withId(R.id.greet_button)).do(click());onView(withText("Hello Steve!")).compare(matches(isDisplayed())); }
C.
@Test public void greeterSaysHello() {onView(withId(R.id.name_field)).do(typeText("Steve")); onView(withId(R.id.greet_button)).do(click());onView(withText("Hello Steve!")).compare(matches(isDisplayed())); }
Answers
Suggested answer: B

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

A.
mTimerViewModel.getTimer().getValue().toString().observe(new Observer<Long>() { @Overridepublic void onChanged(Long aLong) { callAnyChangeUIMethodHere(aLong)}});
A.
mTimerViewModel.getTimer().getValue().toString().observe(new Observer<Long>() { @Overridepublic void onChanged(Long aLong) { callAnyChangeUIMethodHere(aLong)}});
Answers
B.
mTimerViewModel.getTimer().observe(this, new Observer<Long>() { @Overridepublic void onChanged(Long aLong) { callAnyChangeUIMethodHere(aLong)}});
B.
mTimerViewModel.getTimer().observe(this, new Observer<Long>() { @Overridepublic void onChanged(Long aLong) { callAnyChangeUIMethodHere(aLong)}});
Answers
C.
mTimerViewModel.observe(new Observer<Long>() { @Overridepublic void onChanged(Long aLong) { callAnyChangeUIMethodHere(aLong)}});
C.
mTimerViewModel.observe(new Observer<Long>() { @Overridepublic void onChanged(Long aLong) { callAnyChangeUIMethodHere(aLong)}});
Answers
Suggested answer: B
Total 128 questions
Go to page: of 13