0
ParseRelation<ParseObject> p = country.getRelation("view");
ParseQuery P2 = p.getQuery();

So is it possible to intent the P2 query in the next activity ,so that we can use this query in next activity to fetch the data from parse database.

Manuel
  • 14,274
  • 6
  • 57
  • 130
Saurabh
  • 136
  • 1
  • 1
  • 11

1 Answers1

0

Sadly ParseObject is not parcelable, which would solve hundreds of issues I had with their Android SDK.

But you can surely pass country through its object id.

// Launching...
Intent i = new Intent(context, Destination.class);
i.putExtra(“relationObjectId”, country.getObjectId());
i.putExtra(“relationFieldName”, “view”);
startActivity(i);

// Then in Destination activity..
Intent i = getIntent();
String relationObjectId = i.getStringExtra(“relationObjectId”);
String relationFieldName = i.getStringExtra(“relationFieldName”);
Country country = ParseObject.createWithoutData(Country.class, relationObjectId);
ParseQuery query = country.getRelation(relationFieldName);

Please note that before calling getRelation() again, you might have to use fetchIfNeededInBackground().

natario
  • 24,954
  • 17
  • 88
  • 158
  • @Saurabh the answer is pretty much the same. You can not pass a ParseQuery around, but you can try to serialise it. If it’s in a relation field, you can pass the original objectId and reconstruct the object using ParseObject.createWithoutData. Then it’s easy to get the relation again. – natario Nov 03 '16 at 15:49
  • I think this question is more generic and thus more useful to the site than the other one. – natario Nov 03 '16 at 15:50
  • Hello natario thanks for the reply. So i have my question framed in the link [http://stackoverflow.com/questions/40380817/how-to-intent-a-parse-query]. Robert did provided some information , but i didnt quite get that. The query which i asked you is in the Main Activity .Please check and help me resolve this.| – Saurabh Nov 03 '16 at 15:51
  • Do you have any example for the solution you provided, so i can get a more clear picture on this – Saurabh Nov 03 '16 at 15:54
  • @Saurabh no, but it’s as simple as that. Use the first 4 lines in the calling activity to launch the destination activity, and use the rest in the destination activity (for example onCreate). – natario Nov 04 '16 at 01:02