Android Interview Questions

Anuj Jha
3 min readApr 13, 2019

--

I have compiled a list of interview questions asked on Android.

Objective/Audience: Help Job aspirant who are seeking a job as Android developer to help them prepare better.

  1. Difference in activity and services
    To answer this question you should have understanding of what activity and services do. Once you understand that it will be very easy to explain it.
    For better understanding: https://stackoverflow.com/questions/5050005/what-is-the-difference-between-an-android-activity-and-service
  2. Difference in Activity context Vs Application context
    https://blog.mindorks.com/understanding-context-in-android-application-330913e32514
  3. How Android system Render/draw layout on screen
    https://developer.android.com/guide/topics/ui/how-android-draws
  4. Nested Recycler view and Nested Scroll view — advantage Vs disadvantage or issues
  5. Given an Android app which is very slow ,For ex — UI is lagging and user has to wait a lot to see data on screen. Or May be list view scroll is slow. Where should we start looking into to find the reason.
    Approach: To answer this question you must know how UI rendering happens in android. For ex you can have thousands of item to show in list, but on phones at a time limited set of data is shown. So suppose you open the screen and then you try to load data and do some parsing on those data, you have to be a little smart while doing all these. If you process all data at once it will be performance heavy and will lead to bad User experience. In such cases you should use pagination or Android Paging library. To understand pagination check my post : https://medium.com/@thegraduateguy/pagination-with-recyclerview-in-android-2506c4d09a5c
    Further you should avoid any long running operation on UI thread.
  6. Issues with Async task
    https://blog.danlew.net/2014/06/21/the-hidden-pitfalls-of-asynctask/
  7. Can we change UI from asynchronous task using application context
    https://stackoverflow.com/questions/987072/using-application-context-everywhere
  8. Design handler thread in java
    To answer this one should know how handler thread works in Android. For more information about Handler Thread from Google docs and you can also refer my previous article at below link
    https://medium.com/@thegraduateguy/understanding-handler-looper-and-handler-thread-5cd9bf444802
    You can read about it more and then formulate your answer.
  9. Activity Launch Modes
    https://developer.android.com/guide/components/activities/tasks-and-back-stack#ManifestForTasks
    https://inthecheesefactory.com/blog/understand-android-activity-launchmode/en
  10. Activity/Fragment LifeCycle
    Activity: https://developer.android.com/guide/components/activities/activity-lifecycle
    Fragment: https://developer.android.com/guide/components/fragments
  11. Difference between fragment transaction add and replace
    https://stackoverflow.com/questions/24466302/basic-difference-between-add-and-replace-method-of-fragment/24466345
  12. Permission handling in Android
    Reference: https://developer.android.com/training/permissions/requesting
  13. Difference in Service and Intent Service
    https://www.linkedin.com/pulse/service-vs-intentservice-android-anwar-samir/
  14. Options in Android to do long running task.
    Ans: Handler thread, Async task, Services ,Traditional Java threads
    Be careful while using services as by default it runs on main thread so to do any long running task one must create a separate thread within service,
  15. Does activity instance gets garbage collected after rotation . If activity reference is in AsyncTask , will it cause null pointer after rotation?
    Yes activity can get garbage collected if it’s recreated after rotation and there is no reference of it. If this is used as a weak reference it can cause null pointer exception
  16. Does two activity has same UI thread ?
    NO. There is only one UI thread in Android System.
  17. Difference in UI thread Vs main thread in Android
    https://stackoverflow.com/questions/3261370/is-main-thread-the-same-as-ui-thread
  18. What changes with respect to services came in Android P and Android O
    Ref:
    https://developer.android.com/about/versions/oreo/background
  19. What are content provider ?
    Ref:
    https://developer.android.com/guide/topics/providers/content-provider-basics
  20. What is inter app communication in Android and how to achieve it ?
    Inter app communication is way in android by which two app can communicate and/or send data to each other. Two preferred way to do it Content Provider and AIDL
    For ex whenever we want to see contact detail of any user we can query contact app using content provider.
  21. What is recycler view? How it works? What are it’s advantages over list view?
    https://blog.mindorks.com/how-does-recyclerview-work-internally#:~:text=%20How%20does%20RecyclerView%20work%20internally%3F%20%201,scrapped%20views.%20The%20view%20which%20we...%20More%20
  22. Fragment commit vs commitNow method
    https://medium.com/@bherbst/the-many-flavors-of-commit-186608a015b1#:~:text=commit%20%28%29%20and%20commitAllowingStateLoss%20%28%29%20are%20almost%20identical,saved%20its%20state%2C%20it%20will%20throw%20an%20IllegalStateException.
  23. Android parceable vs serializable interface
    Very good article: https://android.jlelse.eu/parcelable-vs-serializable-6a2556d51538

If you like please give applauds.

You can follow me on Twitter or GitHub

--

--