GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - kdroidFilter/AndroidContextProvider: Android Context Provider is a simple utility library that allows you to easily access the application context from anywhere in your app. This can be especially useful for situations where accessing the context in a static manner is needed.

BranchesTags
Open more actions menu

Latest commit

 

History

11 Commits
11 Commits

Folders and files

NameName
Last commit message
Last commit date
.idea
.idea
 
 
gradle
gradle
 
 
lib
lib
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
build.gradle.kts
build.gradle.kts
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
settings.gradle.kts
settings.gradle.kts
 
 

Repository files navigation

🔧 Android Context Provider

Android Context Provider is a simple utility library that allows you to easily access the application context from anywhere in your app. This can be especially useful for situations where accessing the context in a static manner is needed.

✨ Features

  • 🛠️ Uses 0 dependencies, making it lightweight and easy to integrate.

  • 💪 Easy initialization with your application context.

  • 🎮 Access the application context from any part of your code.

📃 Getting Started

🔍 Installation

The library is available on Maven Central.

To import it into your project, add the following to your build.gradle.kts file:

implementation("io.github.kdroidfilter:androidcontextprovider:1.0.1")

or in Groovy :

implementation 'io.github.kdroidfilter:androidcontextprovider:1.0.1'

⏳ Usage

  1. ✨ Automatic Initialization The ContextProvider is automatically initialized using a ContentProvider, which means you do not need to explicitly initialize it in your Application class. This reduces boilerplate and ensures that the ContextProvider is ready to use as soon as your app launches.

  2. 🔎 Getting the Context

    You can access the application context (not an activity context) from anywhere in your app like this:

    val context = ContextProvider.getContext()
    // Use the context as needed

    or in Java :

    Context context = ContextProvider.getContext();
    // Use the context as needed

⚠️ Important Notes

  • Automatic Initialization: The ContextProvider is initialized automatically via ContentProvider, eliminating the need for manual setup.
  • Error Handling: If you try to get the context before it is initialized, ContextProvider will throw an IllegalStateException. However, with automatic initialization, this scenario is unlikely.

📚 License

This project is licensed under the MIT License - see the LICENSE file for details.

🌐 Contributions

Contributions are welcome! If you find any issues or have improvements to suggest, feel free to open an issue or a pull request on GitHub.

About

Android Context Provider is a simple utility library that allows you to easily access the application context from anywhere in your app. This can be especially useful for situations where accessing the context in a static manner is needed.

central.sonatype.com/artifact/io.github.kdroidfilter/androidcontextprovider

Topics

androidandroid-contentproviderandroid-libraryandroid-utilitiesandroid-utilityandroid-utilsandroid-utils-librarycontextkotlin-android

Resources

Readme
MIT license
Activity

Stars

18 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.