android - Toast is not showing in posting tweet -


this code when user click share button.

 public void onclick(view v) {         switch (v.getid()) {             case r.id.btn_login :                 logintotwitter();                 break;             case r.id.btn_share:                 status = "i'm riding @ taxi name: " + operator.gettext().tostring() + "\n" + "with plate number of: " + plate.gettext().tostring() + "\n" +                         shareedittext.gettext().tostring();                 if(status.trim().length() > 0) {                     new updatetwitterstatus().execute(status);                 } else {                     toast.maketext(this, "message empty!!", toast.length_short).show();                 }                 break;         }     }      class updatetwitterstatus extends asynctask<string, string, void> {          @override         protected void onpreexecute() {             super.onpreexecute();              pdialog = new progressdialog(mainactivity2activity.this);             pdialog.setmessage("posting twitter...");             pdialog.setindeterminate(false);             pdialog.setcancelable(false);             pdialog.show();         }          @override         protected void doinbackground(string... params) {              string status = params[0];              try {                 configurationbuilder builder = new configurationbuilder();                 builder.setoauthconsumerkey(consumerkey);                 builder.setoauthconsumersecret(consumersecret);                  string access_token = sharedpreferences.getstring(pref_key_oauth_token, "");                 string acces_token_secret = sharedpreferences.getstring(pref_key_oauth_secret, "");                  accesstoken accesstoken = new accesstoken(access_token, acces_token_secret);                  twitter twitter = new twitterfactory(builder.build()).getinstance(accesstoken);                  statusupdate statusupdate = new statusupdate(status);                  twitter4j.status response = twitter.updatestatus(statusupdate);              } catch (twitterexception e) {                 e.printstacktrace();             }              return null;         }          @override         protected void onpostexecute(void avoid) {              pdialog.dismiss();              toast.maketext(getapplicationcontext(), "posted twitter!", toast.length_short);              shareedittext.settext("");         }     } 

when content message tweeted toast assign in onpostexecute not working. tweet not sent toast not showing. dont know why. cant identify if tweet being tweeted or not. when try it, tweeted doesnt show toast.

you should use show()

 toast.maketext(getapplicationcontext(), "posted twitter!", toast.length_short).show(); 

and better coding use context variable or activityname.this instead of getapplicationcontext()


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -