Reputation: 41
Why does the code parseUser.getcurrentuser.add("") gives an error? the app crashes and why does it crash because have used this function at other places and it works fine there??enter image description here till this the app works fine but after the button is pressed the app crashes but the logcat gives the correct information but the line after that that is the function causes th program to crash so why does this happen??enter image description here
public boolean onOptionsItemSelected(MenuItem item) {
super.onOptionsItemSelected(item);
if(item.getItemId()==R.id.button3)
{
AlertDialog.Builder text3=new AlertDialog.Builder(this);
final EditText text4=new EditText(this);
text3.setView(text4);
text3.setPositiveButton("tweet", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Log.i("this is a",text4.getText().toString());
ParseUser.getCurrentUser().add("tweet",text4.getText().toString());
}
});
text3.setNegativeButton("this isa",null);
text3.show();
return true;
}
if(item.getItemId()==R.id.button4)
{
ParseUser.logOut();
Intent intent=new Intent(getApplicationContext(),MainActivity.class);
startActivity(intent);
return true;
}
/* if(item.getItemId()==R.id.button5)
{
ParseQuery<ParseUser> b=ParseUser.getQuery();
}*/
return true;
}
Upvotes: 0
Views: 71
Reputation: 306
Its not suppose to be throw an error, Can you please share details of error message or Stack trace. Make sure the 'ParseUser.getCurrentUser()' is not returning null object. Once 'ParseUser.logOut()' called, current user will be null until reinitialised again.
Upvotes: 1