I would like to ask you about the Context and Call Back that Android uses on Android.

Asked 2 years ago, Updated 2 years ago, 122 views

When you use a method like getApplicationContext() on Android, what does that mean?

While studying the Android life cycle, methods such as onCreate() and onStart() are usually called callback methods, but in short, are the methods called by the system called callback methods?

android callback android-context

2022-09-22 16:51

1 Answers

Simply put, you can think of Context as a window through which applications communicate with the Android operating system.

Other OSs or platforms often provide static functions when calling system functions or working closely to the OS.

You don't have to create a separate instance, you can use the system function right away.

Android gets Context and does those tasks through an instance of Context.

See here for more information.

Contexts include ApplicationContext, ActivityContext, and ServiceContext. Contexts have their own lifecycle.

A callback method is simply a method that runs when a particular event occurs.

At each stage of the life cycle, the onCreate() onDestroy() and so on can be invoked, or a specific method can be executed when the button is pressed.

The system can call, or something made by the developer can call. It doesn't matter.


2022-09-22 16:51

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.