I have the following application class for my application. When the application starts, I want to get some settings from the settings and start the background service.
public class MyApplication extends Application { public void onCreate() { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); String key = getResources().getString(R.string.prefkey_updateinterval); ... }
This works fine, but sometimes when I run my program from eclipse "Run" I get this error:
10-10 08:25:47.016: E/AndroidRuntime(26402): Caused by: android.content.res.Resources$NotFoundException: String resource ID
This identifier is from my R.java:
public static final int prefkey_updateinterval=0x7f0a0004;
Since this works fine in most cases, I have to assume that there is some kind of race condition between onCreate and downloadable resources?
If so, is it advisable to read resources in the onCreate app?
If so, is there a better place to initialize the service when the application starts?
android
Tim
source share