Google Associate Android Developer Exam Practice Questions (P. 1)
- Full Access (107 questions)
- Six months of Premium Access
- Access to one million comments
- Seamless ChatGPT Integration
- Ability to download PDF files
- Anki Flashcard files for revision
- No Captcha & No AdSense
- Advanced Exam Configuration
Question #1
What is a correct part of an Implicit Intent for sharing data implementation?
- Aval sendIntent = Intent(this, UploadService::class.java).apply { putExtra(Intent.EXTRA_TEXT, textMessage) ...
- Bval sendIntent = Intent().apply { type = Intent.ACTION_SEND; ...
- Cval sendIntent = Intent(this, UploadService::class.java).apply { data = Uri.parse(fileUrl) ...
- Dval sendIntent = Intent().apply { action = Intent.ACTION_SEND ...
Correct Answer:
D
Create the text message with a string
val sendIntent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_TEXT, textMessage)
type = "text/plain"
}
Reference:
https://developer.android.com/guide/components/fundamentals
D
Create the text message with a string
val sendIntent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_TEXT, textMessage)
type = "text/plain"
}
Reference:
https://developer.android.com/guide/components/fundamentals
send
light_mode
delete
Question #2
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:
- Avar builder = NotificationCompat.Builder(this, CHANNEL_ID) .setContentText("Much longer text that cannot fit one line...") .setStyle(NotificationCompat.BigTextStyle() .bigText("Much longer text that cannot fit one line...")) ...
- Bvar builder = NotificationCompat.Builder(this, CHANNEL_ID) .setContentText("Much longer text that cannot fit one line...") .setLongText("Much longer text that cannot fit one line...")) ...
- Cvar builder = NotificationCompat.Builder(this, CHANNEL_ID) .setContentText("Much longer text that cannot fit one line...") .setTheme(android.R.style.Theme_LongText); ...
Correct Answer:
A
Reference:
https://developer.android.com/training/notify-user/build-notification
A
Reference:
https://developer.android.com/training/notify-user/build-notification
send
light_mode
delete
Question #3
Select correct demonstration of WorkRequest cancellation.
- AworkManager.enqueue(OneTimeWorkRequest.Builder(FooWorker::class.java).build())
- Bval request: WorkRequest = OneTimeWorkRequest.Builder(FooWorker::class.java).build() workManager.enqueue(request) val status = workManager.getWorkInfoByIdLiveData(request.id) status.observe(...)
- Cval request: WorkRequest = OneTimeWorkRequest.Builder(FooWorker::class.java).build() workManager.enqueue(request) workManager.cancelWorkById(request.id)
- Dval request1: WorkRequest = OneTimeWorkRequest.Builder(FooWorker::class.java).build() val request2: WorkRequest = OneTimeWorkRequest.Builder(BarWorker::class.java).build() val request3: WorkRequest = OneTimeWorkRequest.Builder(BazWorker::class.java).build() workManager.beginWith(request1, request2).then(request3).enqueue()
- Eval request: WorkRequest = OneTimeWorkRequest.Builder(FooWorker::class.java).build() workManager.enqueue(request) workManager.cancelWork(request)
Correct Answer:
C
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
C
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
send
light_mode
delete
Question #4
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.
- Aoverride fun dispatchPopulateAccessibilityEvent(event: AccessibilityEvent): Boolean { return super.dispatchPopulateAccessibilityEvent(event).let { completed -> if (text?.isNotEmpty() == true) { event.text.add(text) true } else { completed } } }
- Boverride fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean { return when(keyCode) { KeyEvent.KEYCODE_DPAD_LEFT -> { currentValue-- sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED) true } ... } }
- Coverride fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean { return when(keyCode) { KeyEvent.KEYCODE_ENTER -> { currentValue-- sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CONTEXT_CLICKED) true } ... } }
Correct Answer:
B
Reference:
https://developer.android.com/guide/topics/ui/accessibility/custom-views
B
Reference:
https://developer.android.com/guide/topics/ui/accessibility/custom-views
send
light_mode
delete
Question #5
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:
- Aoverride fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.menu_main, menu) return true }
- Boverride fun onOptionsItemSelected(item: MenuItem): Boolean { menuInflater.inflate(R.menu.menu_main, menu) return super.onOptionsItemSelected(item) }
- Coverride fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.menu.menu_main) }
Correct Answer:
A
Reference:
https://developer.android.com/guide/topics/ui/accessibility/custom-views
A
Reference:
https://developer.android.com/guide/topics/ui/accessibility/custom-views
send
light_mode
delete
All Pages