Whenever I change the orientation, there is an error with the thread and my application closes unexpectedly.
Here is the error code
03-23 11:25:40.021: W/dalvikvm(27571): threadid=14: thread exiting with uncaught exception (group=0x40cecae0)
03-23 11:25:40.021: E/AndroidRuntime(27571): FATAL EXCEPTION: Thread-11869
03-23 11:25:40.021: E/AndroidRuntime(27571): java.lang.NullPointerException
03-23 11:25:40.021: E/AndroidRuntime(27571): at my.app.Methods$1.run(Methods.java:34)
Here is the code for the thread :
SettingsPreferences mSettingsPreferences = new SettingsPreferences(mContext);
public void loadStatistic (final ProgressBar progBar, final SettingsPreferences settPref, final String max, final String progress, final int defaultValue) {
Thread t = new Thread () {
public void run() {
try {
sleep(100);
progBar.setMax(settPref.getInt(max, defaultValue));
progBar.setProgress(settPref.getInt(progress, defaultValue));
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};
t.start();
}