Pages

getteammates.com

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?

SHOW/HIDE ANSWER
When a semi-transparent activity opens making the previous activity partially visible.
Reference
http://developer.android.com/training/basics/activity-lifecycle/pausing.html

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

SHOW/HIDE ANSWER
  • 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.
Reference
http://developer.android.com/training/basics/activity-lifecycle/pausing.html

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

SHOW/HIDE ANSWER
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.
Reference
http://developer.android.com/training/basics/activity-lifecycle/stopping.html

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

SHOW/HIDE ANSWER
  • 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
Reference
http://developer.android.com/training/basics/activity-lifecycle/recreating.html

5. What are some of the advantages of Fragments?

SHOW/HIDE ANSWER
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.
Reference
http://developer.android.com/training/basics/fragments/index.html

6. What is AIDL?

SHOW/HIDE ANSWER
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
Reference
http://developer.android.com/guide/components/aidl.html

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

SHOW/HIDE ANSWER
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?

SHOW/HIDE ANSWER
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?

SHOW/HIDE ANSWER
  • 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.
Reference
http://developer.android.com/preview/api-overview.html

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

SHOW/HIDE ANSWER
  • Runtime Permissions
  • Doze and App Standby
  • BoringSSL
  • Notifications - Removed method Notification.setLatestEventInfo and introduced Notification.Builder
Reference
http://developer.android.com/about/versions/marshmallow/android-6.0-changes.html

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

SHOW/HIDE ANSWER
  • 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)
Reference
http://developer.android.com/about/versions/android-5.0-changes.html

No comments:

Post a Comment