There is an activity with goods,

enter image description here

When you click on the button в корзину you need to add the product to the basket, that is, to another activity , and, accordingly, in another form. The main difficulty in forming and sending an object to another activity . I would appreciate advice.

  • Are you sure that when you add you need to go directly to the basket? - danilshik
  • one
    such things are never made “transferring an object” to the pot that all such architecture will “hang in the air” and collapse at every opportunity. such things are done through the database . each activity makes its requests to the common database and transfer nothing between each other, especially the contents of the basket. An example of the implementation of favorites through the database (the same basket after the fact) - pavlofff

1 answer 1

You can use the following code to send an object to another activity :

 Order myOrder = new Order(); Intent intent = new Intent(CurrentActivity.this, NextActivity.class); intent.putExtra(myOrder); startActivity(intent); 

where the class Order must extend Parcelable

PS I'm not sure that going straight to the basket is a good decision!