0

Getting text from a EditText Field. And attempting to set it to a new CloudObject. But Nothing happens when i click the Button.

 btnUpdteStts.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

 String caption = edtxtPost.getText().toString().trim();

         final CloudObject obj = new CloudObject("Status");
            try {
                obj.set("Cap",caption);
            } catch (CloudException e) {
                e.printStackTrace();
            }
            try {
                obj.save(new CloudObjectCallback() {
                    @Override
                    public void done(CloudObject x, CloudException t) throws CloudException {

                        if(x!=null) {
                            Intent goHome = new Intent(Post.this, HomeRoom.class);
                            startActivity(goHome);
                        }
                    }
                });
            } catch (CloudException e) {
                e.printStackTrace();

       Toast.makeText(Post.this,"Problem",Toast.LENGTH_LONG).show();
            }

        }

    });
animuson
  • 53,861
  • 28
  • 137
  • 147
  • "Nothing happens when i click the Button" - If there is an exception, there is an error log. If x is null, nothing will happen. Those are the only reasons I see in this code for the behavior you describe – OneCricketeer Feb 09 '16 at 04:29

1 Answers1

1

You seem not to have handled the case in the callback where x==null in which case exception t!=null. Print the exception message and you should be able to see the problem.

Nawaz Dhandala
  • 2,046
  • 2
  • 17
  • 23