Activity|LaunchMode|With Lifecycle

  1. What is the activity in android?
  2. The lifecycle of activity(Behaviour of activity with the android ecosystem)?
  3. How many ways to use activity (Launch modes)
  4. What are the changes in the activity lifecycle with launch modes?
  1. In Android, An Activity is one screen of the Android app’s user interface. In that way, an Android activity is very similar to windows in a desktop application, In general, whatever you see in the application comes under the activity.
  2. Any Android activity goes through a certain life cycle during its life inside the Android app. There are so many callbacks method states which get notified from the android ecosystem when the state of activity gets change from creating to destroy.
    Some important and most used of them :
    A) onCreate() → Gets a call when activity is launched or created.
    B) onStart() → Gets a call when activity is started and visible.
    c) onResume() → Gets a call when activity is ready for interaction with the user.
    D) onPause() → Gets a call when activity is not interacting with the user or partially visible.
    E) onStop() → Gets a call when activity is in the background or not visible to the user.
    F) onRestart() → Gets a call when activity is coming back to the foreground from the background.
    G) onDestroy() → Gets a call when activity is no longer available.
<activity
android:name=".MyActivity"
android:launchMode="singleTask">
  1. Use notification activity as singleTop or SingleTnstance based on the requirement.
  2. Use normal flow as standard.
  3. Use singleTask or singleInstance with 3rd party application launch like any payment gateway.
  4. FLAG_NEW_TASK will create activity own task that is a new task for new launch activity.
  5. FLAG_CLEAR_TASK|FLAG_NEW_TASK both used together to clear the task and start a new activity with the blank task. Initially, A new activity will only be part of the new task.
  6. CLEAR_TOP All other activity gets destroyed and the activity with clear top will get onNewIntent() callback.

--

--

--

Senior Android App Developer | Startup | Product base | Java | Kotlin | MVVM | Architecture components | Android Blogger

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Getting Started With GitHub On Ubuntu

Legacy application modernization with microservices

Implementing a flexible notifications system in Elixir using Protocols

How to use Android Jetpack Navigation

Coroutines with Unity

ARM Templates Or Azure Bicep — What Should I Use?

My lifelong love affair with Microsoft Excel

Excel spreadsheet with love letter inside

Abstract Data Types (in Python)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aalishan Ansari

Aalishan Ansari

Senior Android App Developer | Startup | Product base | Java | Kotlin | MVVM | Architecture components | Android Blogger

More from Medium

Quest to a refined Outdoor Experience Android App (Strava and Relive inspired) — Part 3

fragment stuck cannot move to another fragment in Android Navigation

Canvas Draw : Make a custom views

Android DataStore with my POV for beginners’ help