Skip to content

Reusable instrument for simple sharing with popular social networks (Facebook, Twiiter).

License

Notifications You must be signed in to change notification settings

apostolp/Android-Simple-Social-Sharing

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Social Sharing for Android

This project aims to provide a reusable instrument for simple sharing with popular social networks (Facebook, Twiiter).

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)

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();

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

Licensed under the BSD 3-clause

About

Reusable instrument for simple sharing with popular social networks (Facebook, Twiiter).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published