Hey, I'm using the unified preference and it works perfectly fine in two of my devices (smasung galaxy s2 and nexus 4) but when i try it on my galaxy tab it has an exception in the line:
super.onCreate(savedInstanceState);
the exception log:
08-03 22:06:08.619: E/AndroidRuntime(16620): FATAL EXCEPTION: main
08-03 22:06:08.619: E/AndroidRuntime(16620): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.out.goout/com.out.goout.SettingsActivity}: android.app.Fragment$InstantiationException: Unable to instantiate fragment net.saik0.android.unifiedpreference.demo.DemoUnifiedPreferenceActivity$GeneralPreferenceFragment: make sure class name exists, is public, and has an empty constructor that is public
08-03 22:06:08.619: E/AndroidRuntime(16620): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
08-03 22:06:08.619: E/AndroidRuntime(16620): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2122)
08-03 22:06:08.619: E/AndroidRuntime(16620): at android.app.ActivityThread.access$600(ActivityThread.java:140)
08-03 22:06:08.619: E/AndroidRuntime(16620): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228)
08-03 22:06:08.619: E/AndroidRuntime(16620): at android.os.Handler.dispatchMessage(Handler.java:99)
08-03 22:06:08.619: E/AndroidRuntime(16620): at android.os.Looper.loop(Looper.java:137)
08-03 22:06:08.619: E/AndroidRuntime(16620): at android.app.ActivityThread.main(ActivityThread.java:4895)
08-03 22:06:08.619: E/AndroidRuntime(16620): at java.lang.reflect.Method.invokeNative(Native Method)
08-03 22:06:08.619: E/AndroidRuntime(16620): at java.lang.reflect.Method.invoke(Method.java:511)
08-03 22:06:08.619: E/AndroidRuntime(16620): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
08-03 22:06:08.619: E/AndroidRuntime(16620): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
08-03 22:06:08.619: E/AndroidRuntime(16620): at dalvik.system.NativeStart.main(Native Method)
08-03 22:06:08.619: E/AndroidRuntime(16620): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment net.saik0.android.unifiedpreference.demo.DemoUnifiedPreferenceActivity$GeneralPreferenceFragment: make sure class name exists, is public, and has an empty constructor that is public
08-03 22:06:08.619: E/AndroidRuntime(16620): at android.app.Fragment.instantiate(Fragment.java:584)
08-03 22:06:08.619: E/AndroidRuntime(16620): at android.preference.PreferenceActivity.switchToHeaderInner(PreferenceActivity.java:1230)
08-03 22:06:08.619: E/AndroidRuntime(16620): at android.preference.PreferenceActivity.switchToHeader(PreferenceActivity.java:1263)
08-03 22:06:08.619: E/AndroidRuntime(16620): at android.preference.PreferenceActivity.onCreate(PreferenceActivity.java:630)
08-03 22:06:08.619: E/AndroidRuntime(16620): at com.out.goout.SettingsActivity.onCreate(SettingsActivity.java:19)
08-03 22:06:08.619: E/AndroidRuntime(16620): at android.app.Activity.performCreate(Activity.java:5163)
08-03 22:06:08.619: E/AndroidRuntime(16620): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
08-03 22:06:08.619: E/AndroidRuntime(16620): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2061)
08-03 22:06:08.619: E/AndroidRuntime(16620): ... 11 more
08-03 22:06:08.619: E/AndroidRuntime(16620): Caused by: java.lang.ClassNotFoundException: net.saik0.android.unifiedpreference.demo.DemoUnifiedPreferenceActivity$GeneralPreferenceFragment
08-03 22:06:08.619: E/AndroidRuntime(16620): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
08-03 22:06:08.619: E/AndroidRuntime(16620): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
08-03 22:06:08.619: E/AndroidRuntime(16620): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
08-03 22:06:08.619: E/AndroidRuntime(16620): at android.app.Fragment.instantiate(Fragment.java:574)
08-03 22:06:08.619: E/AndroidRuntime(16620): ... 18 more
my code is:
import com.actionbarsherlock.view.MenuItem;
import db.GlobalSettings;
import net.saik0.android.unifiedpreference.UnifiedSherlockPreferenceActivity;
import android.content.Context;
import android.os.Bundle;
public class SettingsActivity extends UnifiedSherlockPreferenceActivity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
setHeaderRes(R.xml.pref_headers);
setSharedPreferencesName("com.out.goout_preferences");
setSharedPreferencesMode(Context.MODE_PRIVATE);
super.onCreate(savedInstanceState);
try
{
getSherlock().getActionBar().setTitle(R.string.title_activity_settings);
getSherlock().getActionBar().setHomeButtonEnabled(true);
getSherlock().getActionBar().setDisplayHomeAsUpEnabled(true);
}
catch (Exception e) {}
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
if(item.getItemId() == android.R.id.home)
{
handleFinish();
finish();
}
return super.onOptionsItemSelected(item);
}
/**this method get the name and the */
private void handleFinish()
{
try
{
if(!GlobalSettings.getSettings(getApplicationContext()).isUserDetSent())
{
String age = GlobalSettings.getSettings(getApplicationContext()).getUserAge();
String gender = GlobalSettings.getSettings(getApplicationContext()).getUserGender();
if(!age.equals("") && !gender.equals(""))
{
//send the details to the server
GlobalSettings.getSettings(getApplicationContext()).setUserDetSent(true);
}
}
}
catch (Exception e){}
}
@Override
public void onBackPressed()
{
handleFinish();
super.onBackPressed();
}
}
your help is much needed.
Thanks in advance.
Best,
Shalom Melamed