DavidOli
DavidOli

Reputation: 105

How to send Object via an intent

I have a class called DownloadInfo that consists of a progressBar and two textView , how can I send it via intent and maintain the object at the other side ?

Upvotes: 1

Views: 60

Answers (1)

faranjit
faranjit

Reputation: 1627

Implement Serializable to DownloadInfo class.

Intent intent = new Intent(Youractivity.this, OtherActivity.class);
Bundle args = new Bundle();
args.putSerializable("downloadInfo", DownloadInfo object);
intent.putExtras(args);

On other side:

if (getIntent().hasExtra("downloadInfo"))
    downloadInfo = (DownloadInfo) getIntent().getExtras().getSerializable("downloadInfo");

Upvotes: 1

Related Questions