I am creating a simple application for android, but i'm running to a weird problem. I have two activities, and a Dictionary IntentService. The Dictionary IntentService just reads a text file stored in the assets folder into a HashMap. Note that I have both activities in the Manifest.
This is all i'm doing :
Intent intent = new Intent(this, AnActivity.class);
startActivity(intent);
Intent intentDict = new Intent(this, DictionaryService.class);
startService(intentDict);
The first activity runs fine, it loads the second activity and shows it's UI on the nexus 7 emulator. But when it tries to run the 2nd Intent I get this OutOfMemory error:
05-02 23:29:48.507: I/dalvikvm(797): at android.os.Handler.dispatchMessage(Handler.java:99)
05-02 23:29:48.507: I/dalvikvm(797): at android.os.Looper.loop(Looper.java:137)
05-02 23:29:48.507: I/dalvikvm(797): at android.os.HandlerThread.run(HandlerThread.java:60)
05-02 23:29:48.517: W/dalvikvm(797): threadid=11: thread exiting with uncaught exception (group=0x40a71930)
05-02 23:29:48.527: E/AndroidRuntime(797): FATAL EXCEPTION: IntentService[DictionaryService]
05-02 23:29:48.527: E/AndroidRuntime(797): java.lang.OutOfMemoryError
05-02 23:29:48.527: E/AndroidRuntime(797): at java.util.HashMap.makeTable(HashMap.java:555)
05-02 23:29:48.527: E/AndroidRuntime(797): at java.util.HashMap.doubleCapacity(HashMap.java:575)
05-02 23:29:48.527: E/AndroidRuntime(797): at java.util.HashMap.put(HashMap.java:405)
05-02 23:29:48.527: E/AndroidRuntime(797): at java.util.HashSet.add(HashSet.java:95)
05-02 23:29:48.527: E/AndroidRuntime(797): at com.example.androidApp.Dictionary.readInData(Dictionary.java:73)
05-02 23:29:48.527: E/AndroidRuntime(797): at com.example.androidApp.Dictionary.<init>(Dictionary.java:35)
Now the problem is that, when I do these individually they work fine. So if I run one of the two intents the application works normally. I've tried calling the DictionaryService intent from the newly loaded activity (AnActivity) but that results in the same error. Also with the emulator it has 1024 Mb of RAM allocated so it's not like it doesn't have enough memory. Any ideas?
Thanks