ExamGecko
Home / Google / Associate Android Developer / List of questions
Ask Question

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

List of questions

Question 61

Report
Export
Collapse

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.)

It gives a warning if no field names match.
It gives a warning if no field names match.
It gives a warning if only some field names match.
It gives a warning if only some field names match.
It gives an error if no field names match.
It gives an error if no field names match.
It gives an error if only some field names match.
It gives an error if only some field names match.
Suggested answer: B, C
asked 18/09/2024
walterio mendez
32 questions

Question 62

Report
Export
Collapse

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

Application
Application
Layouts
Layouts
Activities
Activities
Services
Services
AlarmManager
AlarmManager
WorkManager
WorkManager
Broadcast receivers
Broadcast receivers
Content providers
Content providers
Fragments
Fragments
Suggested answer: C, D, G, H
asked 18/09/2024
steven Hughes
37 questions

Question 63

Report
Export
Collapse

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

Intent sendIntent = new Intent(this, UploadService.class) sendIntent.putExtra(Intent.EXTRA_TEXT, textMessage);
Intent sendIntent = new Intent(this, UploadService.class) sendIntent.putExtra(Intent.EXTRA_TEXT, textMessage);
Intent sendIntent = new Intent(); sendIntent.setType(Intent.ACTION_SEND);
Intent sendIntent = new Intent(); sendIntent.setType(Intent.ACTION_SEND);
Intent sendIntent = new Intent(this, UploadService.class) sendIntent.setData(Uri.parse(fileUrl));
Intent sendIntent = new Intent(this, UploadService.class) sendIntent.setData(Uri.parse(fileUrl));
Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND);
Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND);
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

asked 18/09/2024
Luca Arcuri
28 questions

Question 64

Report
Export
Collapse

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:

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..."))
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..."))
.
.
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..."))
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..."))
.
.
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID).setContentText("Much longer text that cannot fit one line...") .setTheme(android.R.style.Theme_LongText); ...
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID).setContentText("Much longer text that cannot fit one line...") .setTheme(android.R.style.Theme_LongText); ...
Suggested answer: A

Explanation:

Reference:

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

asked 18/09/2024
Mk Cheng
43 questions

Question 65

Report
Export
Collapse

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

workManager.enqueue(new OneTimeWorkRequest.Builder(FooWorker.class).build());
workManager.enqueue(new OneTimeWorkRequest.Builder(FooWorker.class).build());
WorkRequest request = new OneTimeWorkRequest.Builder(FooWorker.class).build(); workManager.enqueue(request);LiveData<WorkInfo> status = workManager.getWorkInfoByIdLiveData(request.getId()); status.observe(...);
WorkRequest request = new OneTimeWorkRequest.Builder(FooWorker.class).build(); workManager.enqueue(request);LiveData<WorkInfo> status = workManager.getWorkInfoByIdLiveData(request.getId()); status.observe(...);
WorkRequest request = new OneTimeWorkRequest.Builder(FooWorker.class).build(); workManager.enqueue(request);workManager.cancelWorkById(request.getId());
WorkRequest request = new OneTimeWorkRequest.Builder(FooWorker.class).build(); workManager.enqueue(request);workManager.cancelWorkById(request.getId());
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();
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();
WorkRequest request = new OneTimeWorkRequest.Builder(FooWorker.class).build(); workManager.enqueue(request); workManager.cancelWork(request);
WorkRequest request = new OneTimeWorkRequest.Builder(FooWorker.class).build(); workManager.enqueue(request); workManager.cancelWork(request);
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

asked 18/09/2024
ERIC LUM
40 questions

Question 66

Report
Export
Collapse

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.

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

Explanation:

Reference:

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

asked 18/09/2024
Marcin Piotrowski
40 questions

Question 67

Report
Export
Collapse

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:

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

Explanation:

Reference:

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

asked 18/09/2024
Melih Sivrikaya
37 questions

Question 68

Report
Export
Collapse

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?

UiObject appItem = device.findObject(new UiSelector().className(ListView.class).instance(1).childSelector(new UiSelector().text("Apps")));
UiObject appItem = device.findObject(new UiSelector().className(ListView.class).instance(1).childSelector(new UiSelector().text("Apps")));
UiObject appItem = device.findObject(new UiSelector().className("android.widget.ListView").instance(0).childSelector(new UiSelector().text("Apps")));
UiObject appItem = device.findObject(new UiSelector().className("android.widget.ListView").instance(0).childSelector(new UiSelector().text("Apps")));
UiObject appItem = device.findObject(new UiSelector().className("android.widget.ListView").instance(new UiSelector().text("Apps")));
UiObject appItem = device.findObject(new UiSelector().className("android.widget.ListView").instance(new UiSelector().text("Apps")));
Suggested answer: B
asked 18/09/2024
Joe Mon
29 questions

Question 69

Report
Export
Collapse

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

@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())); }
@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())); }
@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())); }
@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())); }
@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())); }
@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())); }
Suggested answer: B
asked 18/09/2024
Balazs Jarmy
48 questions

Question 70

Report
Export
Collapse

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?

mTimerViewModel.getTimer().getValue().toString().observe(new Observer<Long>() { @Overridepublic void onChanged(Long aLong) { callAnyChangeUIMethodHere(aLong)}});
mTimerViewModel.getTimer().getValue().toString().observe(new Observer<Long>() { @Overridepublic void onChanged(Long aLong) { callAnyChangeUIMethodHere(aLong)}});
mTimerViewModel.getTimer().observe(this, new Observer<Long>() { @Overridepublic void onChanged(Long aLong) { callAnyChangeUIMethodHere(aLong)}});
mTimerViewModel.getTimer().observe(this, new Observer<Long>() { @Overridepublic void onChanged(Long aLong) { callAnyChangeUIMethodHere(aLong)}});
mTimerViewModel.observe(new Observer<Long>() { @Overridepublic void onChanged(Long aLong) { callAnyChangeUIMethodHere(aLong)}});
mTimerViewModel.observe(new Observer<Long>() { @Overridepublic void onChanged(Long aLong) { callAnyChangeUIMethodHere(aLong)}});
Suggested answer: B
asked 18/09/2024
Alajauan Adams
35 questions
Total 128 questions
Go to page: of 13
Search

Related questions