Jarrod Barfield Jarrod Barfield - 3 months ago 10
Android Question

App crash when I submit a new post to Parse

This is the only Place my app crashes and one of the more important features

The LogCat tells me:


java.lang.IllegalArgumentException: You must create this type of ParseObject using ParseObject.create() or the proper subclass.
at line 37.


I tried the
ParseObject.create()
however that just caused more problems (I may have done it incorrectly). How Should I code this?

Here is my newPost class:

public class newPost extends Activity {

private Button addButton;

private TextView postView;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.newpost);

postView = ((EditText) findViewById(R.id.postView));

addButton = ((Button) findViewById(R.id.addButton));
addButton.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
//line 37 Below
ParseObject post = new ParseObject("Posts");
post.put("content", postView);
post.saveInBackground(new SaveCallback () {

@Override
public void done(ParseException e) {
if (e == null) {
setResult(RESULT_OK);
finish();
} else {
Toast.makeText(getApplicationContext(),
"Error saving: " + e.getMessage(),
Toast.LENGTH_SHORT)
.show();
}
}

});

}
});



}

Answer

Replace this line

ParseObject post = new ParseObject("Posts");

with this

ParseObject post = ParseObject.create("Posts");