Code example for ListFragment

Methods: getActivity, startActivityForResult

0
	private void editAlarm(int position) {
		Log.d(TAG, String.format("editAlarm(%d)", position));
		AlarmModel alarm = null;
		if (position >= 0)
			alarm = mAlarms.get(position);
		Intent intent = new Intent(getActivity(), EditAlarmActivity.class);
		intent.putExtra("alarm", alarm);
		intent.putExtra("position", position);
		startActivityForResult(intent, EDIT_ALARM_REQUEST);
	} 
 
	@Override 
	public void onActivityResult(int requestCode, int resultCode, Intent data) {
		switch (requestCode) {
		case EDIT_ALARM_REQUEST:
			if (data != null) {
				Bundle bundle = data.getExtras();
				AlarmModel alarm = bundle.getParcelable("alarm");
				int position = bundle.getInt("position");
				if (position >= 0)
					mAlarms.remove(position);