I am currently working on a proximity alert Android App.There is a listItem_pos key that I don't understand how it has been declared. It's this line
int listItemPos = callerIntent.getIntExtra(getString(R.string.listitem_pos), -1);
In the code below. Is it done automatically when a user raises a new alert?
private void setPreferences() {
boolean isNewAlert = callerIntent.getBooleanExtra(getString(R.string.new_alert), true);
SharedPreferences.Editor editor = defaultSharedPreferences.edit();
if (isNewAlert) {
editor.putBoolean(getString(R.string.preference_turnon_key),false);
editor.putString(getString(R.string.preference_alertname_key), "");
editor.putString(getString(R.string.preference_address_key), "");
editor.putString(getString(R.string.preference_radius_key), "1000");
editor.commit();
} else {
int listItemPos = callerIntent.getIntExtra(getString(R.string.listitem_pos), -1); // <- here
if (listItemPos != -1) {
AlertEntity alertEntity = AlertListManager.getAlertEntityAtListPos(listItemPos);
editor.putBoolean(getString(R.string.preference_turnon_key),alertEntity.enabled);
editor.putString(getString(R.string.preference_alertname_key),alertEntity.name);
editor.putString(getString(R.string.preference_address_key),alertEntity.address);
editor.putString(getString(R.string.preference_radius_key),alertEntity.radius);
editor.commit();
}
}
}
Aucun commentaire:
Enregistrer un commentaire