/**
*
* background에서 수행할 작업을 구현해야 함. execute(…) 메소드에 입력된 인자들을 전달 받음.
* 소스에서는 String 인자
*
*/
@Override
protected
Boolean doInBackground(String... params) {
Boolean isSuccess =
false
;
try
{
String consumerKey = STATICVALUES.consumerKey;
String consumerSecret = STATICVALUES.consumerSecret;
twitter =
new
TwitterFactory().getInstance();
twitter.setOAuthConsumer(consumerKey ,consumerSecret);
AccessToken accessToken =
new
AccessToken(params[
0
], params[
1
]);
twitter.setOAuthAccessToken(accessToken);
twitter.updateStatus(params[
2
]);
isSuccess =
true
;
}
catch
(TwitterException e) {
isSuccess =
false
;
e.printStackTrace();
}
return
isSuccess;
}
/**
* doInBackground(…)가 리턴하는 값을 바탕으로 UI스레드에 background 작업 결과를 표현하도록 구현 함.
**
*/
@Override
protected
void
onPostExecute(Boolean isSuccess) {
super
.onPostExecute(isSuccess);
if
(isSuccess)
{
Toast.makeText(context,
"글쓰기 성공!"
, Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(context,
"글쓰기 실패!"
, Toast.LENGTH_SHORT).show();
}
dialog.dismiss();
}