I am working on an Android app with a Parse backend. The app allows a user to select a row from a list view (driven by parse data) and transition to a detail activity. I would like to pass the ParseObject's objectId from the selected listview cell to the detail activity by using an intent. I can easily pass most information, such as the name, but it doesn't seem to send the objectId, despite being shown as a String on the Parse Dashboard. How does everyone else handle this?
Sending Side:
Intent i = new Intent(getApplicationContext(), EventDetailActivity.class);
ParseObject singleEvent = groupArray.get(position);
String parseID = (String) singleEvent.get("objectId");
i.putExtra("name", parseID);
startActivity(i);
Receiving Side:
Intent i = getIntent();
eventName.setText(i.getStringExtra("name"));
I think it's not possible to send ParseObjectId
using Intent
. It's possible to pass the string ParseObjectId
using Intent
and then to next screen to again convert into a parse object as shown below.
ParseObject object = new ParseObject("ClassName");
object.getObjectId().toString();
String str_obj = object.getObjectId().toString();
Intent i = new Intent();
i.putExtra("objectId", str_obj);
// in next screen
String getObj;
getObj = getIntent().getStringExtra("objectId");
ParseObject oo = new ParseObject("ClassName");
oo.setObjectId(getObj);
Otherwise, it's stored as public
and may be used in the whole application.
You can use .getObjectId()
to get Id in Parse like this:
ParseObject gameScore = new ParseObject("GameScore");
String objectId = gameScore.getObjectId();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.