Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Passing object from Activity to Service

I follow this link Pass data from activity to service for understanding the passage of data from Activity to Service Android. The problem is that I need to pass a complex object to Service. How can I achieve this task?

like image 698
GVillani82 Avatar asked Dec 26 '22 11:12

GVillani82


1 Answers

You can make your complex object implement Serializable or Parcelable and then you can pass it to Service using putExtra(String name, Serializable value) or putExtra(String name, Parcelable value)

Here you can find a tutorial for implementing Parcelable and here Serializable one.

If you aren't familiar with an any of them I would suggest you to use `Serializable' since it's more simple and pretty straightforward

like image 166
Vladimir Mironov Avatar answered Jan 03 '23 00:01

Vladimir Mironov