Simple Social Sharing


Source link: https://github.com/nostra13/Android-Simple-Social-Sharing

! THIS PROJECT IS NO LONGER BEING MAINTAINED !

Simple Social Sharing for Android

This project aims to provide a reusable instrument for simple sharing with popular social networks (Facebook, Twiiter). Project uses other open source projects' code (actual on 25.02.2012):

Features

  • Simple API for Facebook and Twitter sharing (fast indroduction)
  • Simple API for event listening (authentication, posting, logging out)
  • Support only simple sharing (post message or image to Facebook, post status to Twitter)

Important: In your Twitter Developer Application Settings ( https://dev.twitter.com/) you must fill "Callback URL" field with any URL (i.e. http://abc.de). It's behaviour by default.

There are two classes in SSS:

  • TwitterDialog
  • CallbackTwitterDialog

CallbackTwitterDialog is used by default and it works only when "Callback URL" is filled in your Twitter Application settings. You may not use callback URL. Then you should clear "Callback URL" field in app settings and replace all using CallbackTwitterDialog with TwitterDilaog (in TwitterFacade class).

Usage

Sharing API

Facebook

FacebookFacade facebook = new FacebookFacade(activity, FACEBOOK_APP_ID);
 if (!facebook.isAuthorized()) {
  facebook.authorize();
 
}
 facebook.publishMessage("This is great App!");
 facebook.logout();

More powerful posting:

Map actions = new HashMap<String, String>();
 actions.put("Android Simple Social Sharing", "https://github.com/nostra13");
 facebook.publishMessage("Look at this great App!",

 "Use Android Simple Social Sharing in your project!",

 "https://github.com/nostra13/Android-Simple-Social-Sharing",

 "Also see other projects of nostra13 on GitHub!",

 "http://.......facebook-android-logo-1.jpg",

 actions);

Twitter

TwitterFacade twitter = new TwitterFacade(context, TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET);
 if (!twitter.isAuthorized()) {
  twitter.authorize();
 
}
 twitter.publishMessage("This is great app!");
 twitter.logout();

Event listening API

Facebook

...  @Override  protected void onStart() {

super.onStart();

FacebookEvents.addAuthListener(authListener);

FacebookEvents.addPostListener(postListener);

FacebookEvents.addLogoutListener(logoutListener);
  
}

@Override  protected void onStop() {

super.onStop();

FacebookEvents.removeAuthListener(authListener);

FacebookEvents.removePostListener(postListener);

FacebookEvents.removeLogoutListener(logoutListener);
  
}

private AuthListener authListener = new AuthListener() {

@Override
public void onAuthSucceed() {

 showToastOnUIThread("Facebook authentication is successful");

}

 @Override
public void onAuthFail(String error) {

 showToastOnUIThread("Error was occurred during Facebook authentication");

}
  
}
;
private PostListener postListener = new PostListener() {

@Override
public void onPostPublishingFailed() {

 showToastOnUIThread("Post publishing was failed");

}

 @Override
public void onPostPublished() {

 showToastOnUIThread("Posted to Facebook successfully");

}
  
}
;
private LogoutListener logoutListener = new LogoutListener() {

@Override
public void onLogoutComplete() {

 showToastOnUIThread("You are logged out");

}
  
}
;
private void showToastOnUIThread(final String text) {

runOnUiThread(new Runnable() {

 @Override
 public void run() {

  Toast.makeText(YourActivity.this, text, Toast.LENGTH_SHORT).show();

 
}

}
);
  
}
 ...

Twitter

Like Facebook listening example but use TwitterEvents instead of FacebookEvents.

License

Copyright (c) 2011, Sergey Tarasevich

If you use Simple Social Sharing code in your application you should inform the author about it ( email: nostra13[at]gmail[dot]com). Also you should (but you don't have to) mention it in application UI with string "Used Simple-Social-Sharing (c) 2011, Sergey Tarasevich" (e.g. in some "About" section).

Licensed under the BSD 3-clause

Resources

Sliding cards with pretty gallery effects.

ActionQueue allows you run action one by one.

Android library to control Transition animates. A simple way to create an interactive animation.

Make random object fly on your screen.

TextView with pictures wrapping and other effects.

Tool which allows to quickly try the demo project of any Android Library

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