I am working through an app in Android Studio that passes data using intent for school. I have created my object to pass the data through and started the Intent
but I keep getting a warning that my putExtra
method cannot be resolved. Any ideas?
Thanks in advance.
public class MainActivity extends AppCompatActivity {
private ContactInfo contactobject;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Bundle extra = getIntent().getExtras();
contactobject = (ContactInfo)extra.get("contact");
if (contactobject == null )
contactobject = new ContactInfo();
TextView name1 = (TextView) findViewById(R.id.Name1);
name1.setText(contactobject.getOneName());
TextView phone1 = (TextView) findViewById(R.id.Phone1);
phone1.setText(contactobject.getOnePhone());
TextView email1 = (TextView) findViewById(R.id.Email1);
email1.setText(contactobject.getOneEmail());
TextView kin1 = (TextView) findViewById(R.id.Kin1);
kin1.setText(contactobject.getOneKin());
TextView name2 = (TextView) findViewById(R.id.Name2);
name2.setText(contactobject.getTwoName());
TextView phone2 = (TextView) findViewById(R.id.Phone2);
phone2.setText(contactobject.getTwoPhone());
TextView email2 = (TextView) findViewById(R.id.Email2);
email2.setText(contactobject.getTwoEmail());
TextView kin2 = (TextView) findViewById(R.id.Kin2);
kin2.setText(contactobject.getTwoEmail());
}
public void EditPrimary(View view)
{
Intent intent1 = new Intent(getApplicationContext(), Edit1.class);
Intent intent = intent1.putExtra("contact", contactobject);
startActivity(intent1);
}
}