This code seems to work fine on everything except when I emulate it on Froyo. I don’t have an actual device running Froyo, so I can’t test it on an actual device, but it FC’s when it get’s to the commit. I even have the code in a try block, so I would think that it should catch an exception instead of force closing.
private void getPrefs() {
boolean dockRespond;
boolean carDockRespond;
boolean silenceRinger;
settings = getSharedPreferences(PREFS_NAME, 0);
editor = settings.edit();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
dockRespond = prefs.getBoolean("dockRespond", true);
carDockRespond = prefs.getBoolean("carDockRespond", true);
silenceRinger = prefs.getBoolean("silenceRinger", false);
Intent startDock = new Intent(this, DockService.class);
if(dockRespond)
{
//start dock listener service
startService(startDock);
}
else
{
//stop dock listener service
stopService(startDock);
}
try
{
editor.putBoolean(DOCKRESPONSEGLOBAL, dockRespond);
editor.putBoolean(CARDOCKRESPONSEGLOBAL, carDockRespond);
editor.putBoolean(SILENCERINGER, silenceRinger);
editor.commit();
}
catch (Exception e)
{
Log.d("Exception caught: ", e.getMessage());
}
}
All of the constants (in all caps) are defined above in the constants area, and as I said before, the code seems to work on any OS version except Froyo. In froyo it FC’s on the “editor.commit();” line.
Any suggestions?
I figured it out. What was happening was that I was putting myself into an endless loop. I had to:
make my changes, then
Not sure why that only created an issue in Froyo. Google must have made a change in the OS to prevent this in future versions.