Twitter-Helper - A helper library that helps making twitter integration easy

Overview

Twitter-Helper (Not Maintaining Anymore)

A Twitter integration library for Android that helps making twitter integration very easy. Using Twitter Helper you can:

  • Login and logout from Twitter
  • Post Simple Tweets
  • Post Tweets with Image

Before integrating Twitter into your Android app you need to create it on Twitter Developer site

Configuring App on Twitter

Skip this step if you have already got twitter app configured.

You will need a consumer key and a consumer secret (collectively, a “Twitter app”) to use Twitter helper. You can create or review an application’s settings at Twitter’s developer site

  • Go to your Twitter application’s settings at Twitter’s developer site.
  • Find your application and go to the permissions tab.
  • Select the appropriate permissions for your needs (e.g. “Read and write”)
  • If you are using login, add a placeholder URL in the Callback URL field (eg. “http://example.com”).
  • Click update settings.

Allow Sign in with Twitter:

If you wish to use Login with Twitter, be sure that Allow this application to be used to Sign in to Twitter is checked:



Follow the guidelines below in order to integrate Twitter into your Android app. The guidelines defined below are based on Eclipse so you might need to add it as module when your using Android Studio

Adding Twitter Helper

Download and Add Twitter Helper as Library project

Adding the Permission

Add internet permission to your project

 <uses-permission android:name="android.permission.INTERNET" />
   

Initializing Twitter Helper

You can initialize the Twitter Helper in either your Application class or in the start of your launch Activity.

TwitterHelper.initialize(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET);

If you forget to initialize Twitter Helper then it will cause exceptions. so DONT FORGET TO INITIALIZE Twitter Helper Singleton

Logging In to Twitter

Once you have initialized the Twitter helper singleton then you can call the login method of Twitter Helper class like this.

TwitterHelper.logIntoTwitter(mContext, new TwitterLoginCallback() {
			
			@Override
			public void onLoginSuccess() {
				// Login Successfull so move Forward
				
			}
			
			@Override
			public void onLoginFailed(Exception e) {
				// Login Failed
				
			}
		});

In case of successfull login the auth key is automatically saved in Shared Preferences and would be used for posting tweets.

Posting Simple Tweets and Tweets with Images on Twitter

If your not logged in then this method will automatically start the login process. Once logged in to Twitter, you can post tweets on Twitter using the postStatusInBackground method.

The 3rd argument in the method below is for bitmapImage.

  • You can pass in null for posting simple tweets.
  • You can pass in bitmapImage for posting tweets with images.
TwitterHelper.postStatusInBackground(context, tweet, bitmapImage, showProgressDialog, new TwitterStatusCallback() {
			
			@Override
			public void onPostSuccessfull(Status status) {
				// Post Successfull
				
			}
			
			@Override
			public void onPostFailed(Exception e) {
				// Post Failed
				
			}
		});

Logout From Twitter

You can call the method below once you want to logout from Twitter. This method will delete the auth token from shared preferences and the next time you would have to login again.

 TwitterHelper.logoutFromTwitter();
   

License

Copyright 2015 Sheraz Ahmad Khilji

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.

For those who use this library don't forget to tell me how was it

HAPPY CODING ^_^

You might also like...
Android library which makes it  easy to handle the different obstacles while calling an API (Web Service) in Android App.
Android library which makes it easy to handle the different obstacles while calling an API (Web Service) in Android App.

API Calling Flow API Calling Flow is a Android library which can help you to simplify handling different conditions while calling an API (Web Service)

Compose easy forms validation library

Compose EasyForms Focus on building your form UI while the library do the heavy work for you. Features Built in support for most of the Form widgets i

[] Easy async loading for Android's ListView/GridView

NOTE: Smoothie's API is not final yet. Although the library is fairly funcional, this is still beta-quality code. Do not rely on it for production cod

Access and process various types of personal data in Android with a set of easy, uniform, and privacy-friendly APIs.
Access and process various types of personal data in Android with a set of easy, uniform, and privacy-friendly APIs.

PrivacyStreams PrivacyStreams is an Android library for easy and privacy-friendly personal data access and processing. It offers a functional programm

Easy SharedPreference Engine foR ANDROid

esperandro Easy SharedPreference Engine foR ANDROid What? esperandro makes it simple to use SharedPreferences in a nicer and less error-prone way. Wit

It's finally easy to take photos/videos via camera or get photos/videos from gallery on Android.
It's finally easy to take photos/videos via camera or get photos/videos from gallery on Android.

Shutter-Android It's finally easy to take photos/videos via camera or get photos/videos from gallery on Android. What is Shutter? Shutter is an Androi

An easy-to-use, cross-platform measurement tool that pulls data out of CD pipelines and analysis the four key metrics for you.
An easy-to-use, cross-platform measurement tool that pulls data out of CD pipelines and analysis the four key metrics for you.

Maintained by SEA team, ThoughtWorks Inc. Read this in other languages: English, 简体中文 Table of Contents About the Project Usage How to Compute Contrib

Interactive prompts made easy!
Interactive prompts made easy!

Interactive prompts made easy!

This is a easy way to publish MQTT message and receive MQTT message

SMQ-CLIENT This is a easy way to publish MQTT message and receive MQTT message This is provider a spring stater for quick use Recive message form the

Comments
  • logout function

    logout function

    your library is awsome it works really well, but just the Logout function is not working, after calling TwitterHelper.logoutFromTwitter() also it login's again directly

    opened by georgethomas2015e 1
Owner
Sheraz Ahmad Khilji
Technology geek by mind, OpenSource enthusiast by nature and Android developer by profession. (ノ・ェ・)ノ
Sheraz Ahmad Khilji
A helper library to ease the most repetitive codes with simple reusable attributes.

ak-universal-android-helper A helper library to ease the most repetitive codes with simple reusable attributes. AKUAH can help you with many repetitiv

Aakash Kumar 20 Jul 8, 2020
A set of helper classes for using dagger 1 with Android components such as Applications, Activities, Fragments, BroadcastReceivers, and Services.

##fb-android-dagger A set of helper classes for using dagger with Android components such as Applications, Activities, Fragments, BroadcastReceivers,

Andy Dennie 283 Nov 11, 2022
Generate helper methods for compose navigation using KSP

Compose NavGen Generate helper methods for compose navigation using KSP. ?? You can try it now, but it's still under development. ?? TODO Support defa

Kenji Abe 6 Feb 5, 2022
Item Helper For Kotlin

Item Helper For Kotlin

Blugon 2 Dec 3, 2021
XClipper is a clipboard manager for Windows & Android which helps to track clipboard activities and makes it easier to interact with them.

XClipper XClipper is a clipboard manager for Windows & Android which helps to track clipboard activities and makes it easier to interact with them ❤️

Kaustubh Patange 134 Dec 31, 2022
Simple Mobile Tools 172 Dec 26, 2022
KDoctor - A command-line tool that helps to set up the environment for Kotlin Multiplatform Mobile app development

KDoctor is a command-line tool that helps to set up the environment for Kotlin Multiplatform Mobile app development.

Kotlin 331 Dec 29, 2022
:iphone: [Android Library] Get device information in a super easy way.

EasyDeviceInfo Android library to get device information in a super easy way. The library is built for simplicity and approachability. It not only eli

Nishant Srivastava 1.7k Dec 22, 2022
Very easy to use wrapper library for Android SharePreferences

Treasure English document Treasure是一个Android平台上基于SharePreferences的偏好存储库,只需要定义接口,无需编写实现,默认支持Serializable和Parcelable。运行时0反射,不仅使用方便而且性能和原生写法几乎无差别。 使用方法 1

星一 507 Nov 12, 2022
A simple and easy to use stopwatch and timer library for android

TimeIt Now with Timer support! A simple and easy to use stopwatch and timer library for android Introduction A stopwatch can be a very important widge

Yashovardhan Dhanania 35 Dec 10, 2022