hello everybody, This is subrat, i have some problem with preference screen. in my preference screen there are 4 checkboxes & 2 lists. so, my problem is if i do any change to checkbox or list(means, if i check one unchecked checkbox or vice versa as, or i select a value from list), i want 2 post the edited data to server for save(i am using axis server), when i press the button. but here when i am pressing the back button after edited there is no change. i am expecting some help . i don't know why i am not able to connect to server.
here is my code: package com.microaiddreamworks.gps; import java.io.BufferedReader; import java.io.InputStreamReader; import org.kobjects.util.Csv; import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.ksoap2.transport.HttpTransportSE; import com.microaiddreamworks.util.*; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.graphics.Color; import android.os.Bundle; import android.preference.CheckBoxPreference; import android.preference.ListPreference; import android.preference.Preference; import android.preference.PreferenceActivity; import android.preference.PreferenceManager; import android.preference.Preference.OnPreferenceClickListener; import android.telephony.TelephonyManager; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.CheckBox; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; public class TestPreference extends PreferenceActivity{ private SharedPreferences m_cSharedPreferences = null ; private String m_cSafeZoneAlert = "0"; private String m_cOnlineTracking = "0"; private String m_cSpeedAlert = "20"; private String m_cBreadCrumbing = "1"; private String m_cLowBatteryAlert = "0"; private String m_cWhereIsLookup = "0"; ServerMethods m_cObjServer_Methods = null; private String m_clRetVal = null; boolean CheckBoxPreference = false; String ListPreference = null; @Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); // Load the preferences from an XML resource addPreferencesFromResource(R.xml.testpreference); getWindow().setBackgroundDrawableResource(R.drawable.White); getListView().setBackgroundColor(Color.TRANSPARENT); getListView().setCacheColorHint(Color.TRANSPARENT); // getWindow().setTitleColor(Color.BLACK); // View view = ((Preference) m_cSharedPreferences).getView(null,null); // ((TextView)view.findViewWithTag(android.R.id.title)).setTextColor(Color.BLACK); m_cSharedPreferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); m_cObjServer_Methods = new ServerMethods(); } private void SaveConfigToServer() { // TODO Auto-generated method stub try{ CheckBoxPreference = m_cSharedPreferences.getBoolean("checkbox_preference1", false); m_cSafeZoneAlert = String.valueOf(CheckBoxPreference); CheckBoxPreference = m_cSharedPreferences.getBoolean("checkbox_preference2", false); m_cOnlineTracking = String.valueOf(CheckBoxPreference); CheckBoxPreference = m_cSharedPreferences.getBoolean("checkbox_preference3", false); m_cLowBatteryAlert = String.valueOf(CheckBoxPreference); CheckBoxPreference = m_cSharedPreferences.getBoolean("checkbox_preference4", false); m_cWhereIsLookup = String.valueOf(CheckBoxPreference); ListPreference = m_cSharedPreferences.getString("list_preference1", "speed_alert"); m_cSpeedAlert = ListPreference; ListPreference = m_cSharedPreferences.getString("list_preference2", "bread_crumb"); m_cBreadCrumbing = ListPreference; /*m_cSpeedAlert = ((Preference) m_cSharedPreferences).getSharedPreferences().getString("list_preference1","speed_alert"); m_cBreadCrumbing = ((Preference) m_cSharedPreferences).getSharedPreferences().getString("list_preference2", "bread_crumb"); m_cSafeZoneAlert = String.valueOf((((Preference) m_cSharedPreferences).getSharedPreferences().getBoolean("checkbox_preference1", false))?1:0); m_cOnlineTracking = String.valueOf((((Preference) m_cSharedPreferences).getSharedPreferences().getBoolean("checkbox_preference2", false))?1:0); m_cLowBatteryAlert = String.valueOf((((Preference) m_cSharedPreferences).getSharedPreferences().getBoolean("checkbox_preference", false))?1:0); m_cWhereIsLookup = String.valueOf((((Preference) m_cSharedPreferences).getSharedPreferences().getBoolean("checkbox_preference3", false))?1:0); */ TelephonyManager mTelephonyMgr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); String imei = mTelephonyMgr.getDeviceId(); m_clRetVal = m_cObjServer_Methods.editSetting(imei,m_cSafeZoneAlert,m_cOnlineTracking,m_cSpeedAlert,m_cBreadCrumbing,m_cLowBatteryAlert,m_cWhereIsLookup); if(null != m_clRetVal){ Intent btnIntent = new Intent(this, ThisGps.class); startActivity(btnIntent); }else{ alertbox("ThisGPS Settings","settings Failed"); } } catch(Exception pEx){ System.out.println(pEx.toString()); } } protected void alertbox(String title, String mymessage) { new AlertDialog.Builder(this) .setMessage(mymessage) .setTitle(title) .setCancelable(true) .setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton){ if(null != m_clRetVal){ Intent btnIntent = new Intent(); btnIntent.setClass(TestPreference.this, ThisGps.class); startActivity(btnIntent); } } }) .show(); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { SaveConfigToServer(); return true; } return false; } @Override public boolean onKeyUp(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { // SaveConfigToServer(); return true; } return false; } } Thanking yoy, Best Regards Subrat Kumar Panda. India. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en