Giter VIP home page Giter VIP logo

android-interview-questions's Introduction

Android interview questions that I've faced so far or I think is important

I'm creating this repository after getting rejected from ShareChat

Android Components

Explain briefly all the Android application components

App components are the essential building blocks of an Android app. Each component is an entry point through which the system or a user can enter your app. There are four different types of app components :

  • Activities - An activity is the entry point for interacting with the user. It represents a single screen with a user interface.
  • Services - A service is a general-purpose entry point for keeping an app running in the background for all kinds of reasons. It is a component that runs in the background to perform long-running operations or to perform work for remote processes.
  • Broadcast receivers - A broadcast receiver is a component that enables the system to deliver events to the app outside of a regular user flow, allowing the app to respond to system-wide broadcast announcements.
  • Content providers - A content provider manages a shared set of app data that you can store in the file system, in a SQLite database, on the web, or on any other persistent storage location that your app can access.

What is an Activity?

An activity provides the window in which the app draws its UI. This window typically fills the screen, but may be smaller than the screen and float on top of other windows. Generally, one activity implements one screen in an app. For instance, one of an app’s activities may implement a Preferences screen, while another activity implements a Select Photo screen.


Activity Lifecycle

Activity Lifecycle (in execution order) -

Method Called When
onCreate() Activity is first created.
onStart() Activity is becoming visible to the user.
onResume() Activity will start interacting with the user.
onPause() Activity is not visible to the user.
onStop() Activity is no longer visible to the user.
onRestart() After activity is stopped, prior to start.
onDestroy() Before activity is destroyed.

*Note - The onCreate() and onDestroy() methods are called only once throughout the activity lifecycle.

Uses case of activity lifecycle with execution order

When activity is opened:
onCreate()

onStart()

onResume()
When moved to another activity:

Here A == first activity and B == second activity

onPause() - (A)

onCreate() - (B)

onStart() - (B)

onResume() - (B)

onStop() - (A)
When another activity is closed and moving back to first activity:
onPause() - (B)

onRestart() - (A)

onStart() - (A)

onResume() - (A)

onStop() - (B)

onDestroy() - (B)

onStart vs onResume

onStart() -> called when the activity becomes visible, but might not be in the foreground (e.g. an AlertFragment is on top or any other possible use case).

onResume() -> called when the activity is in the foreground, or the user can interact with the Activity.

onPause vs onStop

onPause() -> If you can still see any part of it (Activity coming to foreground either doesn't occupy the whole screen, or it is somewhat transparent).

onStop() -> If you cannot see any part of it

A dialog, for example, may not cover the entire previous Activity, and this would be a time for onPause() to be called


General Questions

  • Tell me about Dependency Injection
  • Tell me about Jetpack Libraries
  • Why shoud we use an app architecture and what are the best practices? read
  • What are Services, Broadcast receivers and Content providers? read
  • Tell me about the Manifest file, what is it's role? read

android-interview-questions's People

Contributors

hellosagar avatar vaibhav2002 avatar miihir79 avatar rohitjakhar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.