code: private synchronized static Context recoverAppContext()
    {
      try
      {
        final Class<?> activityThreadClass = Class.forName( "android.app.ActivityThread" );
        final Method method = activityThreadClass.getMethod( "currentApplication" );
  
        Application app = (Application) method.invoke( null, (Object[]) null );
        return app.getApplicationContext();
      }
      catch ( NoSuchMethodException e )
      {
        return recoverAppContextOldAndroid();
      }
      catch ( Throwable e )
      {
        e.printStackTrace();
      }
      return null;
    }
docs: Magic methods