简体   繁体   中英

Android module supporting different languages (without application context)

I was trying to develop an android module with support for different languages. I can create a strings .xml file but without appropriate context i cannot access it. For the sake of simplicity and to hold on to clean architectural concepts i don't want to receive any context parameters( some parts are meant to live longer than usual ). I have also tried using Kotlin data structures for the purpose, but they doesn't look like a good practice.

so, Is there any recommended way of doing this? or Is there anything that con be done to have asset or resource files accessible from independent modules without any application context ?

If you want to access resource files, you have to use context. Or you can use static variables if you are determined not to use context, which is not a preferred way. You can pass resources as a param which can be provided by creating statically or by dependency injection.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM