Context is an abstract class, whose implementation is provided by Android System. It provide acces to application related resources,databses,shared preferences... We have different ways to access the context. When to use getContext()? Any instance which is not running long time, there we can use getContext(). We can use it in long running instances but we need to hanlde it by theire lifecycle methods to avoid memory leaks. When to use getBaseContext()? Inside activity life cycle we can use the getBaseContext(), this will be lives until the activity lifecycle alive. When to use getApplicationContext()? getApplicationContext() returns the application context of entire application. It will live untile the application life cycle, once application terminated it will destory When to use getThemedContext()? This context will be used to hanlde the views theme context inside the actionbar. Note: we have to use proper context on the lifecycle of each instance to avoid the memory leaks in the application.
Error: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path
Android FCM not receiving notifications when app is removed from background
'constructor Handler()' is deprecated. Deprecated in Java, How to use Handler() class in And
How to Generate signed apk with android studio
How to find Android Device UDID or unique ID?
Explain Fragment Life Cycle
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
How to Exit android app on back pressed?
What are the notifications available in android?
How to stop EditText focus at Activity startup in Android?
INSTALL_FAILED_INVALID_APK: Split lib_slice_9_apk was defined multiple times. It is possible that th
What is the Different Between val and var in Kotlin?
How to get screen size (width,height) in Android?
What are symmetric and asymmetric encryption in the way Android interacts with the server?
How to get an image resource by it's name in android?
How to copy database from assets folder in android using kotlin
What are Android Versions available?
How to convert milli seconds to hours, minutes and seconds in Android?
What is Android Fragments?
How to reduce APK package size?
Duplicate files during packaging of APK” build.gradle issue: Android Studio
Could not inflate Behavior subclass android.support.design.widget. BottomSheetBehavior How resolve
How do I generate random numbers in Dart?
How to get a contact image using a phone number in android?
What is NetworkOnMainThread Exception?
Intent for Drive PDF Viewer - How to open PDF in Google Drive with intent
What is Application?
How do i load image from drawable folder in Jetpack Compose?
How to get complete address from latitude and longitude?
Android Activity FullScreen - How to set activity to fullscreen mode in Android?
What is the difference between match_parent and fill_parent?
Invoke-customs are only supported starting with android 0 --min-api 26
How to validate email address in Android with Kotlin?
How do I check in SQLite whether a table exists?
What happens next when the device switches between portrait and landscape?
How can i comment inside xml file in android studio?
Permission denied for window type 2010 in Marshmallow device
Key Points to remember while develop the Android Application.
How to save activity State in Android?
ERROR Android emulator gets killed when I try to run my application and choose an emulator it ret