public class SettingsActivity extends PreferenceActivity implements OnPreferenceClickListener{
private Preference mLoginPreference;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings_layout);
mLoginPreference = getPreferenceManager().findPreference(
getString(R.string.login_pref));
}
@Override
public boolean onPreferenceClick(Preference preference) {
if(preference.getKey().equals(getString(R.string.login_pref))) {
Intent intent = new Intent(SettingsActivity.this, FacebookLoginActivity.class);
startActivity(intent);
return true;
}
return false;
}
}
In settings_layout.xml
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@android:color/white" >
<Preference
android:key="@string/login_pref"
android:title="@string/login_title" />
</PreferenceScreen>
I have an app which as settings screen, In this Login to your Account option is there which will login FB account of the user and summary will be updated.
Here is a code I written, but it is not working and also i want to update the summary of the Login to your Account whether user is logged in or not using FaceBook Account.
Any Help, Thanks
Once login is done inside
FacebookLoginActivityyou can set the result code usingsetResult(Result code) before finishing the activity and insideSettingsActivityoverrideonActivityResult(Result code) and change the label that user is logged in.