Java tutorial
/* Copyright (c) 2013, Panteha Saeedi All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ahuralab.mozaic; import twitter4j.Twitter; import twitter4j.TwitterException; import com.ahuralab.mozaic.app.TwitterClient; import com.ahuralab.mozaic.auth.TwitterAuthenticator; import com.ahuralab.mozaic.db.Message; import android.content.Context; import android.os.AsyncTask; import android.util.Log; import android.widget.EditText; public class ReplyTask extends AsyncTask<Void, Void, Boolean> { private final Context context; private final String userName; private final String reply; public ReplyTask(Context context, String userName, String reply) { this.context = context; this.userName = userName; this.reply = reply; } @Override protected Boolean doInBackground(Void... params) { // TODO use global authenticator TwitterAuthenticator auth = new TwitterAuthenticator(); Twitter twitter = auth.createTwitter(context); TwitterClient client = new TwitterClient(twitter); try { client.replyTweetMessage(userName, reply); } catch (TwitterException e) { Log.e(TimelineActivity.TAG, "" + e.getMessage(), e); return false; } return true; } }