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 android.content.Context; import android.os.AsyncTask; import android.util.Log; import com.ahuralab.mozaic.app.TwitterClient; import com.ahuralab.mozaic.auth.TwitterAuthenticator; public class UnFollowTask extends AsyncTask<Void, Void, Boolean> { private final Context context; private final String userScreenName; public UnFollowTask(Context context, String userScreenName) { this.context = context; this.userScreenName = userScreenName; } @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.destroyFriendship(userScreenName); } catch (TwitterException e) { Log.e(TimelineActivity.TAG, "" + e.getMessage(), e); return false; } return true; } }