Gin Rummy Indian Rummy Nine Men's Morris and more Air Attack

Wednesday, 9 March 2016

Advanced Android Interview Questions and Answers 4

1. Describe a scenario where an Activity enters pause state but not stop state?

When a semi-transparent activity opens making the previous activity partially visible.

2. What kind of actions are suggested to perform on onPause callback of an Activity implementation?

  • Stop animations or other ongoing actions that could consume CPU
  • Possibly commit unsaved changes
  • Release system resources such as broadcast receivers, handles to camera, sensors, etc.

3. Describe a scenario where onRestart will be called for an Activity implementation?

User launches a new activity B from activity A. And then the user presses back button on activity B.
Here onStop will be called for activity A when user launched activity B. Once user presses back button on activity B, onRestart, onStart and onResume callback are called for activity A.

The onRestart() method, however, is called only when the activity resumes from the stopped state.

4. Describe some of the scenario where an activity could possibly be destroyed?

  • User presses back button
  • finish() method is called for the Activity
  • The Activity is inactive for long time
  • Foreground Activity requires more resources so the system must shut down background processes to recover memory

5. What are some of the advantages of Fragments?

Fragments allows us to modularize the Activity.
Fragments helps us in splitting up views for some devices(phone, tablets) or based on orientations(landscape, portrait).
Fragments helps us to create reusable views.

6. What is AIDL?

AIDL stands for Android Interface Definition Language and is used to define the programming interface that the client and server uses to communicate with each other using (IPC).
Following data types are supported by AIDL,
  • primitive types : int, long, char, boolean, etc.
  • String
  • CharSequence
  • List
  • Map

7. What are some of the cases that you would need to handle when using AsyncTask?

Screen rotation : Suppose the device is rotated then the Activity will be recreated making the reference to the Activity invalid. This would even cause memory leaks as the AsyncTask might have a reference to the Activity or worse Views or the AsyncTask is implemented as a nested class of the Activity.
Activity is destroyed: This is very similar to the first one, AsyncTask continues to execute even if the Activity is destroyed.
Need to explicitly implement the cancel logic : If AsyncTask.cancel() is called then AsyncTask.isCancelled() returns true and developer is supposed to handle the AsyncTask.isCancelled() being true case.
By default AsyncTasks has just one worker thread

8. What are the contents of an APK file?

APK(Android application package) is the file format used by Android for distributing and installing apps and software component.
Some of the contents of APK file are,
  • Manifest file in its binary format
  • Certificate of the application
  • Library files for different platform(armeabi, armeabi-v7a, x86, etc)
  • Compiled resource files
  • Asset files
  • classes.dex : Classes compiled in dex file format

9. What are some of the features introduced in Android N?

  • Multi-window support - Users can now open two apps on the screen at once.
  • Notification enhancements - Bundled notifications, Direct reply, Custom views, Template updates
  • Improvement in Doze mode - Doze mode applied in two phases. Any time the screen is off for a period of time and the device is unplugged, Doze applies a subset of the familiar CPU and network restrictions to apps. When the device is stationary again, with screen off and on battery for a period of time, Doze applies the full CPU and network restrictions on PowerManager.WakeLock, AlarmManager alarms, and GPS/Wi-Fi scans.
  • Vulkan API - New graphics API from Khronos Group
  • Quick Settings Tile API
  • Number-blocking - Supports number blocking in the platform itself and provides a framework API to let service providers maintain a blocked-number list.
  • Call screening - CallScreeningService introduced to screen incoming calls.
  • Direct boot - Improved device startup time. Rather than at first boot, apps are compiled Just-in-Time the first time you launch them.

10. What are some of the features introduced in Android Marshmallow?

  • Runtime Permissions
  • Doze and App Standby
  • BoringSSL
  • Notifications - Removed method Notification.setLatestEventInfo and introduced Notification.Builder

11. What are some of the features introduced in Android Lollipop?

  • Material design
  • Android Runtime (ART) - ART runtime replaces Dalvik as the platform default.
  • Platform support for 64-bit architectures
  • Notifications - Notifications now appear on the user's lock screen, heads-up notification (a small floating window that allows the user to respond or dismiss without leaving the current app)