AndroidTwitter


Source link: https://github.com/lorensiuswlt/AndroidTwitter

AndroidTwitter

AndroidTwitter is a small android library to let you connect to Twitter and access all it's public API (tweet status, retweet, etc).

How to Use

Here is a sample activity ( TestConnect.java) to show how to connect to Twitter then save the access token. The access token then can be used later to access Twitter's public API (see TestPost.java)

public class TestConnect extends Activity {
  private TwitterApp mTwitter;  private CheckBox mTwitterBtn;
private static final String twitter_consumer_key = "xxx";  private static final String twitter_secret_key = "xxxx";
@Override  public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

 setContentView(R.layout.main);

 mTwitterBtn = (CheckBox) findViewById(R.id.twitterCheck);

 mTwitterBtn.setOnClickListener(new OnClickListener() {

 @Override
 public void onClick(View v) {

  onTwitterClick();

 
}

}
);

 mTwitter  = new TwitterApp(this, twitter_consumer_key,twitter_secret_key);

 mTwitter.setListener(mTwLoginDialogListener);

 if (mTwitter.hasAccessToken()) {

 mTwitterBtn.setChecked(true);

  String username = mTwitter.getUsername();

 username  = (username.equals("")) ? "Unknown" : username;
  mTwitterBtn.setText("  Twitter (" + username + ")");

 mTwitterBtn.setTextColor(Color.WHITE);

}

 Button goBtn = (Button) findViewById(R.id.button1);

 goBtn.setOnClickListener(new OnClickListener() {

 @Override
 public void onClick(View v) {

  startActivity(new Intent(TestConnect.this, TestPost.class));

 
}

}
);
  
}

private void onTwitterClick() {

if (mTwitter.hasAccessToken()) {

 final AlertDialog.Builder builder = new AlertDialog.Builder(this);

  builder.setMessage("Delete current Twitter connection?")

  .setCancelable(false)

  .setPositiveButton("Yes", new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog, int id) {

 mTwitter.resetAccessToken();

  mTwitterBtn.setChecked(false);

 mTwitterBtn.setText("  Twitter (Not connected)");

 mTwitterBtn.setTextColor(Color.GRAY);

}

  
}
)

  .setNegativeButton("No", new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog, int id) {

  dialog.cancel();

mTwitterBtn.setChecked(true);

}

  
}
);

 final AlertDialog alert = builder.create();

  alert.show();

}
 else {

 mTwitterBtn.setChecked(false);

  mTwitter.authorize();

}
  
}

private final TwDialogListener mTwLoginDialogListener = new TwDialogListener() {

@Override
public void onComplete(String value) {

 String username = mTwitter.getUsername();

 username  = (username.equals("")) ? "No Name" : username;
  mTwitterBtn.setText("  Twitter  (" + username + ")");

 mTwitterBtn.setChecked(true);

 mTwitterBtn.setTextColor(Color.WHITE);

  Toast.makeText(TestConnect.this, "Connected to Twitter as " + username, Toast.LENGTH_LONG).show();

}

 @Override
public void onError(String value) {

 mTwitterBtn.setChecked(false);

  Toast.makeText(TestConnect.this, "Twitter connection failed", Toast.LENGTH_LONG).show();

}
  
}
; 
}
 

This library requires external jar files from Twitter4J and Oauth-signpost, see http://www.londatiga.net/it/how-to-post-twitter-status-from-android/ for more information.

Developed By

Changes

See CHANGELOG for details

License

Copyright 2011 Lorensius W. L. T  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. 

Resources

This is a picture select Android library that supports camera to take pictures, picture gallery multiple choice, image shearing!

This is an android in the Dialog library, not based on a systematic way to achieve Dialog using Activity root view of the Add Dialog, it has strong scalability and customizability.

Animated counting TextView component for Android. With CountingTextView you can enumerate a TextView with given start and end values.

This is a cool radio button group!

This library allows to manage debug logs.

AndroLua is the Lua interpreter ported to the Android platform. Others have ported Lua to Android, but this project is special:

  • it includes LuaJava, so you can access (almost) everything the Android API provides
  • because writing code on the soft keyboard can be hard, you can connect to it using TCP an upload code from your computer

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes