Está en la página 1de 16

4/20/2016

How To Integrate Twitter In Android Application | Java Techig

Gmail for Work

HOME

ANDROID

XAMARIN

Look more professional with


custom Gmail from Google

OTHER TUTORIALS

CODE SNIPPETS

Start free trial

BLOG

How To Integrate Twitter In


Android Application
By NILANCHALA SEP 12, 2014
Tweet

Share

ANDROID

53 COMMENTS

Search tutorials, articles & more..

-- Advertisement --

This tutorial explains,how to integrate twitter in android


application.The example below using twitter4j java library for login
to twitter and allows to posttext and image in users twitters
timeline.This application involves following steps
1. Download twitter4j jar file
2. Create a new application in Twitter developer console
3. Design your application user interface
4. Allow user to login to twitter and get authentication token

Connect with us

5. Save the token for further use

Javatechig

6. Post text or image content on twitter timeline

1. Download Twitter SDK


Twitter4J is an uno icial Java library for the Twitter API. With
Twitter4J, you can easily integrate your Java application with the

Subscribe to our mailing list to get the


updates to your email inbox.
Your email address

Twitter service. Note that twitter4j is an uno icial library.


You need to download this library before you can start integrating

Subscribe

twitter on android. Download here.


-- Advertisement --

2. Create New Appin Twitter console


1. Visit the below link to login to twitter developer console and
login with your credentials
https://dev.twitter.com/apps
2. You will see a console as shown in the screenshot below. Here
you can see list of applications created on twitter. For our
example let us create a new application by clicking on the
Create a new application button.
3. Fill the required application details like name, description,
website link and callback url. Call back url is optional, so can be
le blank. And move next.
4. Now we are done. You can see your app console as shown in the
http://javatechig.com/android/how-to-integrate-twitter-in-android-application

1/16

4/20/2016

How To Integrate Twitter In Android Application | Java Techig

screenshot below.For twitter integration in android we require


consumer secret and consumer key.

3. Create New Android Application


Now we are ready to start write sample application to integrate
twitter4j sdk in android. Create a new project and add twitter4j

Popular Posts

1.

Android Gridview ExampleBuilding Image Gallery in

core4.0.2.jarto libs folder.

android

In this example, we have two activities. MainActivity and WebView


activity. The MainActivity uses a simple layout that allows user to
login to Twitter, anda er loginuser can share messageon twitter.
The WebViewActivity shows user a login screen through which user
can login to twitter by supplying twitter credentials. Once user is
authenticated, it will be redirected to the MainActivity with the oAuth
response.
Let us have a look into applications layout files.

activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/activity_vertical_margin" >
<RelativeLayout
android:id="@+id/login_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:visibility="visible" >

2.

Navigation Drawer Android


Example

3.

Android RecyclerView Example

4.

Using Facebook SDK in Android


Example

5.

Installing Android Studio

6.

Android ListView Example

7.

How to Get List of Installed Apps


in Android

8.

Loading Image Asynchronously


in Android ListView

9.

YouTubePlayerView Example in
Android Using YouTube API

10. Android WebView Example

<TextView

http://javatechig.com/android/how-to-integrate-twitter-in-android-application

2/16

4/20/2016

How To Integrate Twitter In Android Application | Java Techig


android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="@string/login_instructions"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#0080B4" />
<Button
android:id="@+id/btn_login"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#0080B4"
android:text="@string/btn_login"
android:textColor="#fff" />

AdvertiseHere

</RelativeLayout>
<LinearLayout
android:id="@+id/share_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:visibility="gone" >
<TextView
android:id="@+id/user_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:text="@string/hello"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#0080B4" />
<ImageView
android:id="@+id/imageView"
android:layout_width="fill_parent"
android:layout_height="150dp"
android:scaleType="centerCrop"
android:src="@drawable/lakeside_view" />
<EditText
android:id="@+id/share_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#cceaf3"
android:hint="@string/share_instructions"
android:inputType="textMultiLine"
android:minLines="5"
android:padding="10dp" />
<Button
android:id="@+id/btn_share"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#0080B4"
android:text="@string/btn_share"
android:textColor="#fff" />
</LinearLayout>
</LinearLayout>

The above layout is being used in MainActivity.java. Below is the


layout for WebViewActivity.java

activity_webview.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"

http://javatechig.com/android/how-to-integrate-twitter-in-android-application

3/16

4/20/2016

How To Integrate Twitter In Android Application | Java Techig


android:id="@+id/urlContainer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<WebView
android:id="@+id/webView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/urlContainer" />

</LinearLayout>

The above layout files using few of the strings which are defined in
strings.xml. This file also contains the mandatory twitter

parameters. Please do pasteyour own twitter consumer key and


consumer secret obtained from twitter developer console (Step-1)

strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Strings used in app ui-->
<string name="app_name">TwitterShare</string>
<string name="action_settings">Settings</string>
<string name="hello">Hello, </string>
<string name="login_instructions">Login to twiter</string>
<string name="share_instructions">Enter share message</string>
<string name="btn_login">Login to Twitter</string>
<string name="btn_share">Share</string>
<!-- Twitter Configurations -->
<string name="twitter_callback">http://javatechig.android.app</string>
<string name="twitter_consumer_key">YOUR_CONSUMER_KEY_HERE</string>
<string name="twitter_consumer_secret">YOUR_CONSUMER_SECRET_HERE</string>
<string name="twitter_oauth_verifier">oauth_verifier</string>
<!-- End Configurations -->
</resources>

4. Application Manifest Permissions


In the above two steps, we have declared the layout files and the
strings used in the application. Before we getting into the massive
piece of activity code, let us have a look into our application Manifest
file. In this file, we have declared both the activities used in this
application. Note, this application needs
android.permission.INTERNETpermission and so lets declare it.

Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.twittershare"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="14" />
<!-- Permission - Internet Connect -->
<uses-permission android:name="android.permission.INTERNET" />

http://javatechig.com/android/how-to-integrate-twitter-in-android-application

4/16

4/20/2016

How To Integrate Twitter In Android Application | Java Techig


<!-- Network State Permissions -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.twittershare.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT"
<category android:name="android.intent.category.BROWSABLE"
<data
android:host="t4jsample"
android:scheme="oauth" />
</intent-filter>
</activity>
<activity
android:name="com.example.twittershare.WebViewActivity"
android:label="@string/app_name" />
</application>

</manifest>

MainActivity.java
package com.example.twittershare;
import java.io.InputStream;
import twitter4j.StatusUpdate;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.User;
import twitter4j.auth.AccessToken;
import twitter4j.auth.RequestToken;
import twitter4j.conf.Configuration;
import twitter4j.conf.ConfigurationBuilder;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.StrictMode;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends Activity implements OnClickListener {
/* Shared preference keys */
private static final String PREF_NAME = "sample_twitter_pref";

http://javatechig.com/android/how-to-integrate-twitter-in-android-application

5/16

4/20/2016

How To Integrate Twitter In Android Application | Java Techig


private static final String PREF_KEY_OAUTH_TOKEN = "oauth_token"
private static final String PREF_KEY_OAUTH_SECRET = "oauth_token_secret"
private static final String PREF_KEY_TWITTER_LOGIN = "is_twitter_loggedin"
private static final String PREF_USER_NAME = "twitter_user_name"
/* Any number for uniquely distinguish your request */
public static final int WEBVIEW_REQUEST_CODE = 100;
private ProgressDialog pDialog;
private static Twitter twitter;
private static RequestToken requestToken;
private static SharedPreferences mSharedPreferences;
private EditText mShareEditText;
private TextView userName;
private View loginLayout;
private View shareLayout;
private String consumerKey = null;
private String consumerSecret = null;
private String callbackUrl = null;
private String oAuthVerifier = null;
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/* initializing twitter parameters from string.xml */
initTwitterConfigs();
/* Enabling strict mode */
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy
StrictMode.setThreadPolicy(policy);
/* Setting activity layout file */
setContentView(R.layout.activity_main);
loginLayout = (RelativeLayout) findViewById(R.id.login_layout
shareLayout = (LinearLayout) findViewById(R.id.share_layout
mShareEditText = (EditText) findViewById(R.id.share_text
userName = (TextView) findViewById(R.id.user_name);
/* register button click listeners */
findViewById(R.id.btn_login).setOnClickListener(this);
findViewById(R.id.btn_share).setOnClickListener(this);

/* Check if required twitter keys are set */


if (TextUtils.isEmpty(consumerKey) || TextUtils.isEmpty(
Toast.makeText(this, "Twitter key and secret not configured"
Toast.LENGTH_SHORT).show();
return;
}
/* Initialize application preferences */
mSharedPreferences = getSharedPreferences(PREF_NAME, 0);
boolean isLoggedIn = mSharedPreferences.getBoolean(PREF_KEY_TWITTER_LOGIN
/* if already logged in, then hide login layout and show share layout */
if (isLoggedIn) {
loginLayout.setVisibility(View.GONE);
shareLayout.setVisibility(View.VISIBLE);
String username = mSharedPreferences.getString(PREF_USER_NAME
userName.setText(getResources ().getString(R.string
+ username);
} else {
loginLayout.setVisibility(View.VISIBLE);
shareLayout.setVisibility(View.GONE);

http://javatechig.com/android/how-to-integrate-twitter-in-android-application

6/16

4/20/2016

How To Integrate Twitter In Android Application | Java Techig


Uri uri = getIntent().getData();
if (uri != null && uri.toString().startsWith(callbackUrl
String verifier = uri.getQueryParameter(
try {
/* Getting oAuth authentication token */
AccessToken accessToken = twitter
/* Getting user id form access token */
long userID = accessToken.getUserId
final User user = twitter.showUser
final String username = user.getName
/* save updated token */
saveTwitterInfo(accessToken);
loginLayout.setVisibility(View.GONE
shareLayout.setVisibility(View.VISIBLE
userName.setText(getString(R.string
} catch (Exception e) {
Log.e("Failed to login Twitter!!"
}
}
}
}

/**
* Saving user information, after user is authenticated for the first time.
* You don't need to show user to login, until user has a valid access toen
*/
private void saveTwitterInfo(AccessToken accessToken) {
long userID = accessToken.getUserId();
User user;
try {
user = twitter.showUser(userID);
String username = user.getName();
/* Storing oAuth tokens to shared preferences */
Editor e = mSharedPreferences.edit();
e.putString(PREF_KEY_OAUTH_TOKEN, accessToken.getToken
e.putString(PREF_KEY_OAUTH_SECRET, accessToken.getTokenSecret
e.putBoolean(PREF_KEY_TWITTER_LOGIN, true);
e.putString(PREF_USER_NAME, username);
e.commit();
} catch (TwitterException e1) {
e1.printStackTrace();
}
}
/* Reading twitter essential configuration parameters from strings.xml */
private void initTwitterConfigs() {
consumerKey = getString(R.string.twitter_consumer_key);
consumerSecret = getString(R.string.twitter_consumer_secret
callbackUrl = getString(R.string.twitter_callback);
oAuthVerifier = getString(R.string.twitter_oauth_verifier
}

private void loginToTwitter() {


boolean isLoggedIn = mSharedPreferences.getBoolean(PREF_KEY_TWITTER_LOGIN
if (!isLoggedIn) {

http://javatechig.com/android/how-to-integrate-twitter-in-android-application

7/16

4/20/2016

How To Integrate Twitter In Android Application | Java Techig


final ConfigurationBuilder builder = new ConfigurationBuilder
builder.setOAuthConsumerKey(consumerKey);
builder.setOAuthConsumerSecret(consumerSecret);
final Configuration configuration = builder.build
final TwitterFactory factory = new TwitterFactory
twitter = factory.getInstance();
try {
requestToken = twitter.getOAuthRequestToken
/**
* Loading twitter login page on webview for authorization
* Once authorized, results are received at onActivityResult
* */
final Intent intent = new Intent(this, WebViewActivity
intent.putExtra(WebViewActivity.EXTRA_URL
startActivityForResult(intent, WEBVIEW_REQUEST_CODE
} catch (TwitterException e) {
e.printStackTrace();
}
} else {
loginLayout.setVisibility(View.GONE);
shareLayout.setVisibility(View.VISIBLE);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
if (resultCode == Activity.RESULT_OK) {
String verifier = data.getExtras().getString(oAuthVerifier
try {
AccessToken accessToken = twitter.getOAuthAccessToken
long userID = accessToken.getUserId();
final User user = twitter.showUser(userID
String username = user.getName();
saveTwitterInfo(accessToken);
loginLayout.setVisibility(View.GONE);
shareLayout.setVisibility(View.VISIBLE);
userName.setText(MainActivity.this.getResources
R.string.hello) + username
} catch (Exception e) {
Log.e("Twitter Login Failed", e.getMessage
}
}
super.onActivityResult(requestCode, resultCode, data);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_login:
loginToTwitter();
break;
case R.id.btn_share:
final String status = mShareEditText.getText().toString
if (status.trim().length() > 0) {
new updateTwitterStatus().execute(status
} else {
Toast.makeText(this, "Message is empty!!"
}
break;
}
}

http://javatechig.com/android/how-to-integrate-twitter-in-android-application

8/16

4/20/2016

How To Integrate Twitter In Android Application | Java Techig


class updateTwitterStatus extends AsyncTask<String, String, Void
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(MainActivity.this);
pDialog.setMessage("Posting to twitter...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();
}
protected Void doInBackground(String... args) {
String status = args[0];
try {
ConfigurationBuilder builder = new ConfigurationBuilder
builder.setOAuthConsumerKey(consumerKey);
builder.setOAuthConsumerSecret(consumerSecret
// Access Token
String access_token = mSharedPreferences
// Access Token Secret
String access_token_secret = mSharedPreferences
AccessToken accessToken = new AccessToken
Twitter twitter = new TwitterFactory(builder
// Update status
StatusUpdate statusUpdate = new StatusUpdate
InputStream is = getResources().openRawResource
statusUpdate.setMedia("test.jpg", is);
twitter4j.Status response = twitter.updateStatus
Log.d("Status", response.getText());
} catch (TwitterException e) {
Log.d("Failed to post!", e.getMessage());
}
return null;
}
@Override
protected void onPostExecute(Void result) {
/* Dismiss the progress dialog after sharing */
pDialog.dismiss();
Toast.makeText(MainActivity.this, "Posted to Twitter!"
// Clearing EditText field
mShareEditText.setText("");
}
}

WebViewActivity.java
package com.example.twittershare;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class WebViewActivity extends Activity {

http://javatechig.com/android/how-to-integrate-twitter-in-android-application

9/16

4/20/2016

How To Integrate Twitter In Android Application | Java Techig


private WebView webView;
public static String EXTRA_URL = "extra_url";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_webview);
setTitle("Login");
final String url = this.getIntent().getStringExtra(EXTRA_URL
if (null == url) {
Log.e("Twitter", "URL cannot be null");
finish();
}
webView = (WebView) findViewById(R.id.webView);
webView.setWebViewClient(new MyWebViewClient());
webView.loadUrl(url);
}

class MyWebViewClient extends WebViewClient {


@Override
public boolean shouldOverrideUrlLoading(WebView view, String
if (url.contains(getResources().getString(R.string
Uri uri = Uri.parse(url);
/* Sending results back */
String verifier = uri.getQueryParameter(
Intent resultIntent = new Intent();
resultIntent.putExtra(getString(R.string
setResult(RESULT_OK, resultIntent);
/* closing webview */
finish();
return true;
}
return false;
}
}
}

5. Output

http://javatechig.com/android/how-to-integrate-twitter-in-android-application

10/16

4/20/2016

How To Integrate Twitter In Android Application | Java Techig

6. Download Source Code


Download complete example source code fromGitHub.

Share

Tweet

Nilanchala
A blogger, speaker, author, a bit of tech freak and a
so ware developer. He is a thought leader in the fusion of
design and mobile technologies.
Follow @npanigrahy

RELATED POSTS:

Enable the move to SDCard button for Android App


Android CheckBox Example
Using Custom Activity Transition in GridView Image
Gallery
Android SQLite Database Tutorial
How to Get List of Installed Apps in Android
Android FrameLayout Example
Installing Android Studio

53 Comments

javatechig

Share

Recommend 5

Login

Sort by Newest

Join the discussion


Aryan Roy

2 months ago

great code but i want for studio in fabric which i found on below link.
http://androidtechtutorials.bl...
gr8 code step by step explanation.

Reply Share

Aryan Roy

2 months ago

great...code it really helpful!!


But i faced some fabric installation issue which solved on below
blog. http://androidtechtutorials.bl...
very helpful blog for social login....step by step explaination.

Reply Share

raman rayat

2 months ago

hi thanks for tutorial but after login my app is moving to call back url
it is not coming back and showing share layout screen after loging
...please help me

Reply Share

Samarth Shah 3 months ago


http://javatechig.com/android/how-to-integrate-twitter-in-android-application

11/16

4/20/2016

Samarth Shah

How To Integrate Twitter In Android Application | Java Techig

3 months ago

great..!! it's absolutely working..good work.!!

Reply Share

rakesh kushwaha

4 months ago

hello sir,can we check that our "MyTwitterApp" automatically login


after Twitter(orignal App) login

Reply Share

rakesh kushwaha

4 months ago

hello sir,can we check that our "MyTwitterApp" automatically login


after Twitter(orignal App) login


Tirta

Reply Share

4 months ago

I dunno whats wrong with mine,


but, i got error on import twitter4j.Twitter;
can u help me with that?

Reply Share

Nilanchala Panigrahy

Mod

> Tirta 4 months ago

you need to import twitter4j library.


Reply Share


Tech Morphosis

5 months ago

hurrreyyyyyyy ... happy . Thanks dude .. keep going

Reply Share

Hamza Anas

6 months ago

I've used your code and it works great but you havent explained a lot
of your java code. It would have been helpful to know what these
methods and reserved keywords are and how to use them.

Reply Share

Mu Baig

8 months ago

java.security.cert.CertPathValidatorException: Trust anchor for


certication path not found. This is the error I am getting while
executing your code with your access key and secret key.Also I tried
using my key and secret key with my callback url .I am getting same
error .pls help
Edit:I am using android studio with device samsung notebook

Reply Share

Astha Dangi

10 months ago

Thanks sir this code is really help full for me


but i want to extract user information and then return to my app. how
it is done... plss help

Reply Share

Jaideep Gupta

10 months ago

Thank sir this code works for me


but also i want to get twitter friend list. how is it done

Reply Share

Jaideep Gupta

10 months ago

Hello Sir
this code works for me but I want to get Twitter friend list. How is it
possible?

Reply Share

Anand Kumar

a year ago

awsome tutorial thanks a lot sir


http://javatechig.com/android/how-to-integrate-twitter-in-android-application

12/16

4/20/2016

How To Integrate Twitter In Android Application | Java Techig


anii

Reply Share

a year ago

thanks alotttt works like charm :)


Joy

Reply Share

a year ago

Thanks for Working and Simple example..I am newbie i want to login


into app via twitter..What do i have to change for that,any
suggestions will be helpful
Thanks in Advance

Reply Share

Priyanka

a year ago

hello sir, thanks for sharing code. But i want code in which user can
only follow the twitter account. Please help me

Reply Share

Nilanchala Panigrahy

Mod

> Priyanka a year ago

quite easy. Just use the code below. It should work


twitter.createFriendship("javatechig")

Reply Share

Priyanka > Nilanchala Panigrahy

a year ago

thanks. But where can i add this code? please explain

Reply Share

Nilanchala Panigrahy

Mod

a year ago

> Priyanka

Add this after twitter authentication is done.


Instead of updateTwitterStatus()you can use
twitter.createFriendship()method.

Reply Share

Guest > Nilanchala Panigrahy

a year ago

thanx sir but how where can i add this code? please
explain

Reply Share

Guest > Nilanchala Panigrahy

a year ago

thanx but where can i add this code?

Reply Share

Guest > Nilanchala Panigrahy

a year ago

Thanx but where can i add this code?

Reply Share

Lakshmana Raja Makineedi

a year ago

Thank You so much for this tutorial , this helped me a lot and i want
Facebook integration also can you send that link please . and your
code is perfectly working.

Reply Share

Nilanchala Panigrahy

Mod

a year ago

> Lakshmana Raja Makineedi

Checkout Using Facebook SDK in Android Example tutorial .


Hac zdemir

Reply Share

a year ago

hi javatechig
twitter.shutdown is not recognized for logout from twitter.
http://javatechig.com/android/how-to-integrate-twitter-in-android-application

13/16

4/20/2016

How To Integrate Twitter In Android Application | Java Techig

thanks for reply.


1

Reply Share

Eng Mohammad Rababah

a year ago

hi javatechig
I am using your code but my question is: How I can logout from
twitter?
thanks in advance
Reply Share

JavaTechig

Mod

> Eng Mohammad Rababah a year ago

The following code will help


CookieSyncManager.createInstance(this);
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeSessionCookie();
twitter.setOAuthAccessToken(null);
twitter.shutdown();

Reply Share

ombalakumar > JavaTechig

a month ago

i am getting error in getInstance(),


removeSessionCookie() and shutdown()
Reply Share

Jatin Devani > JavaTechig

10 months ago

i didn't get the shutdown() method what i can do


JavaTechig?
Reply Share


Mohammad Rababah

a year ago

hi all
How I can log out from twitter after using your code
thanks in advance
Reply Share

JavaTechig

Mod

> Mohammad Rababah a year ago

Updated with comment. Please check


BINIL S

Reply Share

a year ago

I tried the app by using my own "Consumer Key" and "Consumer


Secret Key". At that time am getting 401 Authentication error.I put
the correct "key" and the time is syncing.
But by using the your "Key" the app is perfectly working.
Can you please tell me where I was wrong

Reply Share

JavaTechig

Mod

> BINIL S a year ago

Did you create your fresh set of keys? if yes, it takes a while
to get live.

Reply Share

BINIL S > JavaTechig

a year ago

OK, will it get any conformation message after its


getting live

Reply Share

http://javatechig.com/android/how-to-integrate-twitter-in-android-application

14/16

4/20/2016

How To Integrate Twitter In Android Application | Java Techig


JavaTechig

Mod

> BINIL S a year ago

Alright!


Anupreet kaur

Reply Share

a year ago

i Got the toast image posted ...when i check that, there is no new
tweet

Reply Share

Anupreet kaur

a year ago

Its Login but not able to share image

Reply Share

Jenifa mary

a year ago

Anyone plz...help.How to follow us particular user in twitter?

Reply Share

Tom Bruyneel

a year ago

so you're consumer secret is available on the client? Looks like a


very bad solution to me

Reply Share

Md. Imtiaz Hossain Nisat

a year ago

Awesome. Works perfectly. Thanks man :)

Reply Share

peter

a year ago

Hi When i tried this code, it always crashes after i tried to login the
very rst time. Do you know what are the possible reasons?

Reply Share

Arturo Villela

a year ago

I dont know who you are... but i will nd you.. and i will thank you.. :)
atte: charlito.

Reply Share

JavaTechig

Mod

> Arturo Villela a year ago

Thanks Arrturo. By the way you can nd me from my author


prole.


Justin Young

Reply Share

a year ago

Thank you! Been searching everywhere for the last few days on how
to get Twitter4J to work on Android. Even though their ocial site
says it's Android ready. Yours if the rst to work and not have very
complex issues. Now I can make progress on my class's nal
project. =D
For reference my setup is: Eclipse Juno with Android SDK. Twitter4J
4.0.2. Android versions 17, 18, and 19.

Reply Share

JavaTechig

Mod

> Justin Young a year ago

Thanks for sharing your experience.


Mohamed

Reply Share

a year ago

Is it possible to get the user's prole picture after logging in and set it
to an imageview ?

Reply Share

Mohamed a year ago


http://javatechig.com/android/how-to-integrate-twitter-in-android-application

15/16

4/20/2016

ANDROID

How To Integrate Twitter In Android Application | Java Techig

JAVA

WORDPRESS

Search tutorials, articles & more..

ABOUT ADVERTISE CONTACT TERMS OF SERVICE FAQ PRIVACY POLICY CONTRIBUTORS

COPYRIGHT 2015 BY JAVATECHIG. ALL RIGHTS RESERVED.

http://javatechig.com/android/how-to-integrate-twitter-in-android-application

16/16

También podría gustarte