3

I have a singleton that holds a lot of information on my App (ACCU.class). I'm using the application context to do a single initialization and single finishing. One of the key features is another singleton called IMCDefinition that reads from a raw resource named imc.xml. If I call the line IMCDefinition.getInstance(getResources().openRawResource(R.raw.imc)); from an Activity Context it works. From an Application context it doesn't... Following goes the code:

public class App extends Application 
{   
    public App()
    {
        IMCDefinition.getInstance(getResources().openRawResource(R.raw.imc));
        ACCU.getInstance(this);
        System.out.println("Global ACCU Object Initialized");
    }
}
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
JQCorreia
  • 727
  • 6
  • 15
  • you can add it in: "answer your own question" and mark it with "V" i think you can do that only the day after though. if you do it now i don't mind marking it for you :-) – codeScriber Apr 12 '11 at 14:59
  • I cant answer my own question for 24 hours! But thanks anyway Scriber! – JQCorreia Apr 12 '11 at 15:10

1 Answers1

2

Done! You don't get to mess with the Constructor in this class. onCreate() is the way to go. Put your code there. Forget about the question. Should i put this in a separate answer?

JQCorreia
  • 727
  • 6
  • 15
  • THANKS ...DAMN ... i spend so much time in (half an hours ;=) to 3/4 of an hours ;=))) to ******* get this ***** ressource to show ***** – cV2 Apr 18 '12 at 13:42
  • No problem m8. I'm guessing that it's only after the constructor being called that you have access to resource. – JQCorreia Apr 20 '12 at 15:05
  • guess you're right ;=)) if "you" know it, it seems somehow clear, understandable ;=)))) – cV2 Apr 22 '12 at 03:00