-1

My exception:

java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference

Can someone explain to me what this error really relates to? It's been over 5 hours thinking and googling this this out.

chazefate
  • 822
  • 4
  • 13
  • 35
  • 1
    Show your code where calling `getResources ` method. probably Context is null which is used to call `getResources ` – ρяσѕρєя K Jan 11 '16 at 17:42
  • Possible duplicate of [Android Activity Context is Null](http://stackoverflow.com/questions/26071442/android-activity-context-is-null) or http://stackoverflow.com/questions/2002288/static-way-to-get-context-on-android – Nir Alfasi Jan 11 '16 at 17:45

2 Answers2

0

The context on which you are calling getResources() is null.

0

Unless you show us some code, I assume this error has happened because you have treated your Activity objects like ordinary Java objects, not in the Android way. Note that in Android framework, you need to initialize your Activity object using onCreate() method, not simply new myActivityObject. Look at the Activity Lifecycle section here.

Maryam
  • 1
  • 2