pt89
pt89

Reputation: 55

passing and displaying json data between activities not working?

i have a listview of json data and when i click on the specific , i have tried to display the rest of the json data in a new activity by using the intent method. however, this is not working. can someone tell me what i'm doing wrong please?

my code:

Upvotes: 2

Views: 69

Answers (2)

Rami
Rami

Reputation: 7929

Your searchResults variable, is an ArrayList of Strings not a String.

So you need to use putStringArrayListExtra() and getStringArrayListExtra() instead.

eg:

In your first activity:

newActivity.putStringArrayListExtra("title", searchResults);

And in your receiving activity:

 ArrayList<String> searchResults = getIntent().getStringArrayListExtra("title");

Upvotes: 2

Mohammed Aouf Zouag
Mohammed Aouf Zouag

Reputation: 17142

Change

Intent newActivity = new Intent(ResultsActivity.this, MoviePage.class);

to

Intent newActivity = new Intent(ResultsActivity.this, MovieDetails.class);

You are targeting the wrong Activity.

EDIT:

the searchResults variable contains an int, so you have to use getInt() instead of getString().

Upvotes: 1

Related Questions