Search code examples
javaandroidandroid-holo-everywhere

Can't cast Holoeverywhere application to getapplicationcontext


I have extended the application class to add some preference to my app, i started to implement holoeverywhere, and now i'm getting this error:

03-28 10:39:10.020: E/AndroidRuntime(12511): java.lang.ClassCastException: org.holoeverywhere.app.Application cannot be cast to com.myapp.Globals

in this line:

Globals global = (Globals) getApplicationContext();

Thank you.


Solution

  • import org.holoeverywhere.app.Application;
    
    public class Globals extends Application {
      ..
    }
    
    <application android:name="com.package.Globals"
      ..
    />
    
    Globals application = (Globals) getApplication();