MCQs / Computer Science / Intents and Notifications

Intents and Notifications MCQs — Computer Science

38 multiple-choice questions on Intents and Notifications from Computer Science, each with the correct answer and, where available, a teacher's explanation. Read through them to revise the chapter, then practise the same questions one by one to test yourself.

1. To open your own app's settings page, which action is used?

  1. ACTIONSETTINGSAPP
  2. ACTIONMANAGE
  3. Settings.ACTIONAPPLICATIONDETAILSSETTINGS with a package: URI
  4. ACTIONCONFIG

Answer: C) Settings.ACTIONAPPLICATIONDETAILSSETTINGS with a package: URI

Explanation: This settings action opens the App info screen for the package.

Discuss this question

2. Which intent declares only an action and data and lets Android choose the app?

  1. Pending intent
  2. Service intent
  3. Explicit intent
  4. Implicit intent

Answer: D) Implicit intent

Explanation: Implicit intents are resolved through intent filters.

Discuss this question

3. Opening your app from a website link (deep link) uses a filter with:

  1. action VIEW, category BROWSABLE and https data
  2. category LAUNCHER only
  3. action CALL
  4. action SEND

Answer: A) action VIEW, category BROWSABLE and https data

Explanation: Deep links use VIEW + BROWSABLE + data with scheme/host.

Discuss this question

4. If no app can handle an implicit intent, startActivity() throws:

  1. NullPointerException
  2. IOException
  3. SecurityException
  4. ActivityNotFoundException

Answer: D) ActivityNotFoundException

Explanation: Catch ActivityNotFoundException to avoid a crash.

Discuss this question

5. A major benefit of calling built-in apps with implicit intents is that:

  1. The app becomes bigger
  2. It works only on emulators
  3. Your app reuses existing apps' features without implementing them and often without permissions
  4. It removes the need for a manifest

Answer: C) Your app reuses existing apps' features without implementing them and often without permissions

Explanation: The other app (dialer, maps, camera) does the work.

Discuss this question

6. Which intent specifies the exact class of the component to start?

  1. Sticky intent
  2. Implicit intent
  3. Explicit intent
  4. Broadcast intent

Answer: C) Explicit intent

Explanation: Explicit intents include the component name.

Discuss this question

7. Which importance level shows a heads-up pop-up with sound?

  1. IMPORTANCEMIN
  2. IMPORTANCEDEFAULT
  3. IMPORTANCELOW
  4. IMPORTANCEHIGH

Answer: D) IMPORTANCEHIGH

Explanation: High importance makes sound and appears as heads-up.

Discuss this question

8. Which method shows the "Share via" chooser dialog?

  1. Intent.createChooser(intent, "Share via")
  2. showShareSheet()
  3. startChooserActivity()
  4. Intent.share()

Answer: A) Intent.createChooser(intent, "Share via")

Explanation: createChooser wraps an intent so the user always picks an app.

Discuss this question

9. An activity must include which category in its intent filter to receive implicit intents from startActivity()?

  1. CATEGORYLAUNCHER
  2. CATEGORYHOME
  3. CATEGORYDEFAULT
  4. CATEGORYAPPMUSIC

Answer: C) CATEGORYDEFAULT

Explanation: startActivity adds CATEGORYDEFAULT to implicit intents automatically.

Discuss this question

10. Which style shows a long piece of text when the notification is expanded?

  1. BigTextStyle
  2. ProgressStyle
  3. MediaStyle
  4. InboxStyle

Answer: A) BigTextStyle

Explanation: BigTextStyle displays expanded long text.

Discuss this question

11. From Android 12, components with an intent filter must set:

  1. android:exported explicitly (true to receive outside intents)
  2. android:enabled="false"
  3. android:debuggable
  4. android:process

Answer: A) android:exported explicitly (true to receive outside intents)

Explanation: Android 12 requires an explicit exported value.

Discuss this question

12. Which URI scheme shows a location in a maps app?

  1. tel:
  2. geo:
  3. content:
  4. smsto:

Answer: B) geo:

Explanation: geo:lat,lng opens a map application.

Discuss this question

13. A PendingIntent allows:

  1. Sending SMS without permission
  2. Another app or the system to execute your intent later with your app's identity
  3. Running code on another phone
  4. Faster intents

Answer: B) Another app or the system to execute your intent later with your app's identity

Explanation: PendingIntent is a token given to the notification manager, alarms or widgets.

Discuss this question

14. Which URI opens a web page using ACTIONVIEW?

  1. https://www.google.com
  2. geo:www.google.com
  3. mailto:www.google.com
  4. tel:www.google.com

Answer: A) https://www.google.com

Explanation: An http/https URI with ACTIONVIEW opens a browser.

Discuss this question

15. Which call attaches the action performed when the notification is tapped?

  1. setPriority()
  2. setContentIntent(pendingIntent)
  3. setSmallIcon()
  4. setChannelId()

Answer: B) setContentIntent(pendingIntent)

Explanation: setContentIntent sets the PendingIntent fired on tap.

Discuss this question

16. Which element is REQUIRED for every notification?

  1. Big picture
  2. Action button
  3. Large icon
  4. Small icon

Answer: D) Small icon

Explanation: A notification without setSmallIcon() throws an error.

Discuss this question

17. To open the camera app to take a photo, the action used is:

  1. MediaStore.ACTIONIMAGECAPTURE
  2. ACTIONPICTURE
  3. ACTIONSHOOT
  4. ACTIONCAMERA

Answer: A) MediaStore.ACTIONIMAGECAPTURE

Explanation: MediaStore.ACTIONIMAGECAPTURE launches the camera app.

Discuss this question

18. Intent filters are declared in:

  1. build.gradle
  2. MainActivity only
  3. strings.xml
  4. AndroidManifest.xml

Answer: D) AndroidManifest.xml

Explanation: Filters are part of component declarations in the manifest.

Discuss this question

19. Since Android 12, creating a PendingIntent requires:

  1. Specifying FLAGIMMUTABLE or FLAGMUTABLE
  2. Root access
  3. A network connection
  4. A foreground service

Answer: A) Specifying FLAGIMMUTABLE or FLAGMUTABLE

Explanation: Mutability flags are mandatory from API 31.

Discuss this question

20. Notification channels are required from Android:

  1. 10
  2. 8.0 (API 26)
  3. 13
  4. 5.0

Answer: B) 8.0 (API 26)

Explanation: Since Oreo, notifications without a channel are not shown.

Discuss this question

21. Which flag starts an activity in a new task, needed when starting from a non-activity context?

  1. FLAGIMMUTABLE
  2. FLAGSECURE
  3. FLAGKEEPSCREENON
  4. FLAGACTIVITYNEWTASK

Answer: D) FLAGACTIVITYNEWTASK

Explanation: Starting an activity from a service or application context needs NEWTASK.

Discuss this question

22. Users can turn off one category of an app's notifications (e.g. promotions) because of:

  1. Toasts
  2. Notification channels
  3. PendingIntent flags
  4. Intent filters

Answer: B) Notification channels

Explanation: Channels let users control each category separately.

Discuss this question

23. Which of these is NOT one of the three fundamental uses of intents?

  1. Starting an activity
  2. Delivering a broadcast
  3. Starting a service
  4. Compiling a layout

Answer: D) Compiling a layout

Explanation: Intents start activities, start services and deliver broadcasts.

Discuss this question

24. Which three tests does Android perform during intent resolution?

  1. Permission, version, signature
  2. Size, colour, speed
  3. Memory, CPU, battery
  4. Action, category and data tests

Answer: D) Action, category and data tests

Explanation: Implicit intents are matched against filters with the action, category and data tests.

Discuss this question

25. The AndroidX class used to build notifications compatible with all versions is:

  1. Notification.Builder only
  2. AlertDialog.Builder
  3. Toast.Builder
  4. NotificationCompat.Builder

Answer: D) NotificationCompat.Builder

Explanation: NotificationCompat.Builder handles version differences.

Discuss this question

Page 1 of 2 Next

Practise Intents and Notifications MCQs

More Computer Science chapters