I am using parse.com in my android application.when i visit other user's profile , i am able to follow that user but when i follow him value in following column of current logged in user's object is updated, but at the same time the user's value whom i followed is not updated It Gives:
06-27 05:11:44.521: E/AndroidRuntime(2459): java.lang.IllegalArgumentException: Cannot save a ParseUser that is not authenticated.
Here is my android code package com.example.wavie.parseQueryRunner;
import android.content.Context;
import com.parse.GetCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;
import com.parse.ParseUser;
public class FollowUserClass {
private String id;
private Context context;
public FollowUserClass(String id, Context context) {
this.id = id;
this.context = context;
}
public void follow() {
ParseUser currentUser=ParseUser.getCurrentUser();
currentUser.addUnique("following", id);
try {
currentUser.save();
ParseQuery<ParseObject> query=new ParseQuery<ParseObject>("_User");
query.getInBackground(id, new GetCallback<ParseObject>() {
@Override
public void done(ParseObject object, ParseException e) {
// TODO Auto-generated method stub
if(e==null && object!=null){
object.addUnique("followers", ParseUser.getCurrentUser().getObjectId());
try {
object.save();
} catch (ParseException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
});
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
in the code section constructor takes the object id of the user whom i want to follow.first it updates current logged in user adds taken id in following field(array).
then i tried to make update in other user's object by adding line
object.addUnique("followers",
ParseUser.getCurrentUser().getObjectId());
but when i save it gives parse user should be authenticated before ssaving