What I've essentially built is an EditTextView that collects a String, which when input by the user attempts to communicate with the back-end in order to pull the user's "objectId", this being a column in my User database.
The showProfileActivity() function shown below simply works, and I've excluded it because it isn't relevant to the problem. It takes the user's "objectId" and shows the user's profile.
What I want is for "String userId", which is the User's "objectId" in the database to be generated dynamically. I know that the showProfileActivity() function works because I can literally just input a String with the hard-coded objectId and it brings me to that user's profile.
My question is, based on the String input by the user into the search field, how can I retrieve the value in the relevant "objectId" column?
findViewById(R.id.submitSearch).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EditText searchUserTextField = (EditText) findViewById(R.id.searchUserTextField);
// Value input to search field
final String searchInput = searchUserTextField.getText().toString();
// System.out.println(searchInput);
// Initiate ParseQuery
final ParseQuery<ParseUser> query = ParseQuery.getQuery("username");
// Look for the username that was typed into the search field
query.whereEqualTo("username", searchInput);
query.findInBackground(new FindCallback<ParseUser>() {
public void done(List<ParseUser> objects, ParseException e) {
if (e == null) {
// The query was successful.
// This works but clearly always loads the exact same user profile. I need this string to be loaded dynamically as a function of the user's search query.
String userId = "dj16qsXPle";
// System.out.println(userId);
showProfileActivity(userId);
} else {
// Something went wrong.
}
}
});
// Execute RemoteDataTask AsyncTask
new RemoteDataTask().execute();
}
});
}