Voidcode
Voidcode

Reputation: 1259

Passing data between activities in Android(BIG JSON DATA STRING)

How can I pass an big json-string between activities fast?

a) My Activity one look like this.

JsonDataTask jdt = new JsonDataTask(c);

AsyncTask<String, Integer, String> rdataJSON = jdt.execute("https://job.jobnet.dk/FindJobService/V1/Gateway.ashx/annonce?fritekst=akutjob&sortering=match");

try {   
   Intent i = new Intent(c, JoblistActivity.class);
   i.putExtra("rdataJSON", rdataJSON.get());
   startActivity(i);
} catch (InterruptedException e1) {
   e1.printStackTrace();
} catch (ExecutionException e1) {
   e1.printStackTrace();
}

b) Then Activity two below.

Intent intent = getIntent();
JobPosting_json = intent.getStringExtra("rdataJSON");

The problem is where the 'jdt.execute()' a.k.a json-string return too must data.. Then the 'getStringExtra("rdataJSON")' can´t holde the hule string..

Upvotes: 1

Views: 738

Answers (2)

Romain Piel
Romain Piel

Reputation: 11177

So two solutions:

  • or you cache the data in your first activity then get it in the second
  • or you do the request in the second activity

I usually go for the second option but it all depends on your requirements.

Upvotes: 0

kumar_android
kumar_android

Reputation: 2263

You want to use Parcelable class to one activity to another, Refer http://developer.android.com/reference/android/os/Parcelable.html

Upvotes: 1

Related Questions