I know that I can use this with an Activity context, but can I use this method with an Application context instead (so I don't have to pass in a Context variable to a method that utilizes this method?
            Asked
            
        
        
            Active
            
        
            Viewed 680 times
        
    0
            
            
         
    
    
        jwir3
        
- 6,019
- 5
- 47
- 92
- 
                    If you look at the [source](https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/text/format/DateFormat.java) the method just reads the locale from context, so the application context will suffice. – Eugen Pechanec Aug 31 '15 at 18:47
- 
                    @EugenPechanec Is there a way to tell absolutely from the source which one is needed in a given instance? (i.e. how did you know that the application context would suffice if you only need the locale)? – jwir3 Aug 31 '15 at 18:49
- 
                    1Both will return the same value if asked for locale. You only need to provide activity context when inflating widgets and resolving colors and drawables (on API >= 21), so color attributes can be resolved. In any other case application context is fine. – Eugen Pechanec Aug 31 '15 at 18:52
- 
                    Thanks, @EugenPechanec. If you post as an answer, I will accept. – jwir3 Aug 31 '15 at 18:54