witam mam problem wydaje mi się że z przekazaniem danych, lecz nie wiem gdzie jest błąd
komunikat: java.lang.IllegalArgumentException: class com.example.pam3.Person declares multiple JSON fields named mLifecycleRegistry
wycinek z Main
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
Locale locale = new Locale("PL");
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getApplicationContext().getResources().updateConfiguration(config, null);
setContentView(R.layout.activity_main);
firstname = (EditText) findViewById(R.id.imie);
lastname = (EditText) findViewById(R.id.nazwisko);
birthdate = (TextView) findViewById(R.id.dataurodzenia);
street = (EditText) findViewById(R.id.ulica);
dnumber = (EditText) findViewById(R.id.numerd);
mnumber = (EditText) findViewById(R.id.numerm);
city = (EditText) findViewById(R.id.miasto);
pcode = (EditText) findViewById(R.id.kod);
male = (RadioButton) findViewById(R.id.mezczyzna);
female = (RadioButton) findViewById(R.id.kobieta);
swimming = (CheckBox) findViewById(R.id.plywanie);
basketball = (CheckBox) findViewById(R.id.koszykowka);
horseriding = (CheckBox) findViewById(R.id.jazdakonna);
jogging = (CheckBox) findViewById(R.id.bieganie);
soccer = (CheckBox) findViewById(R.id.pilkanozna);
volleyball = (CheckBox) findViewById(R.id.siatkowka);
send = (Button) findViewById(R.id.wyslij);
clear = (Button) findViewById(R.id.wyczysc);
sex = new ArrayList<RadioButton>();
sex.add(male);
sex.add(female);
activities = new ArrayList<CheckBox>();
activities.add(swimming);
activities.add(jogging);
activities.add(horseriding);
activities.add(basketball);
activities.add(volleyball);
activities.add(soccer);
clear.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
clear_all();
}
});
birthdate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Calendar cldr = Calendar.getInstance();
int day = cldr.get(Calendar.DAY_OF_MONTH);
int month = cldr.get(Calendar.MONTH);
int year = cldr.get(Calendar.YEAR);
picker = new DatePickerDialog(MainActivity.this,
new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
birthdate.setText(dayOfMonth + "." + (monthOfYear + 1) + "." + year);
}
}, year, month, day);
picker.show();
}
});
send.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Person person = new Person(
firstname.getText().toString(),
lastname.getText().toString(),
male.isChecked(),
city.getText().toString(),
street.getText().toString(),
dnumber.getText().toString(),
mnumber.getText().toString(),
pcode.getText().toString(),
birthdate.getText().toString()
);
for (CheckBox c : activities) {
if (c.isChecked()) {
person.AddActivity(c.getText().toString());
}
}
StartSummary(person);
}
});
}
public void StartSummary(Person p){
Intent intent = new Intent(MainActivity.this,SummaryActivity.class);
Gson gson = new Gson();
intent.putExtra("person", gson.toJson(p));
this.startActivity(intent);
}
summary activity
public class SummaryActivity extends AppCompatActivity {
TextView summary;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_summary);
summary = (TextView)findViewById(R.id.summary);
Gson gson = new Gson();
String strobj = getIntent().getStringExtra("person");
Person person = gson.fromJson(strobj, Person.class);
summary.setText(person.toString());
}
Person
public class Person extends AppCompatActivity {
public String firstname;
public String lastname;
public boolean male;
public String city;
public String street;
public String dnumber;
public String mnumber;
public String pcode;
public String birthdate;
public List<String> activities = new ArrayList<String>();
public Person(String firstname, String lastname, boolean male, String city, String street, String dnumber, String mnumber, String pcode, String birthdate) {
this.firstname = firstname;
this.lastname = lastname;
this.male = male;
this.city = city;
this.street = street;
this.dnumber = dnumber;
this.mnumber = mnumber;
this.pcode = pcode;
this.birthdate = birthdate;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
public void AddActivity(String toString) {
activities.add(toString);
}
}