- Google+ Tools
-
Make Google+ profile picture
Make Google plus banners for profile
Create and share your Google Plus profile banners.
The main objective of this example is to access social media providers Facebook, Twitter and others by clicking a single button "Share".On Clicking the button the api will open dialog of providers. User can access the provider from dialog and can update the status , get friends list , user profile
Integrate Linkedin, Facebook, Twitter, MySpace in Android App with One SDK
public class ShareButtonActivity extends Activity {
// SocialAuth Component
SocialAuthAdapter adapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Welcome Message
TextView textview = (TextView)findViewById(R.id.text);
textview.setText("Welcome to SocialAuth Demo. We are sharing text SocialAuth Android by share button.");
//Create Your Own Share Button
Button share = (Button)findViewById(R.id.sharebutton);
share.setText("Share");
share.setTextColor(Color.WHITE);
share.setBackgroundResource(R.drawable.button_gradient);
// Add it to Library
adapter = new SocialAuthAdapter(new ResponseListener());
// Add providers
adapter.addProvider(Provider.FACEBOOK, R.drawable.facebook);
adapter.addProvider(Provider.TWITTER, R.drawable.twitter);
adapter.addProvider(Provider.LINKEDIN, R.drawable.linkedin);
adapter.addProvider(Provider.MYSPACE, R.drawable.myspace);
adapter.enable(share);
}
/**
* Listens Response from Library
*
*/
private final class ResponseListener implements DialogListener
{
/**
*
*/
private static final long serialVersionUID = 1L;
public void onComplete(Bundle values) {
// Variable to receive message status
boolean status;
Log.d("ShareButton" , "Authentication Successful");
// Get name of provider after authentication
String providerName = values.getString(SocialAuthAdapter.PROVIDER);
Log.d("ShareButton", "Provider Name = " + providerName);
try
{
// Please avoid sending duplicate message. Social Media Providers block duplicate messages.
adapter.getCurrentProvider().updateStatus("SocialAuth Android" + System.currentTimeMillis());
status = true;
}
catch (Exception e)
{
status = false;
}
// Post Toast or Dialog to display on screen
if(status)
Toast.makeText(ShareButtonActivity.this, "Message posted on " + providerName, Toast.LENGTH_SHORT).show();
else
Toast.makeText(ShareButtonActivity.this, "Message not posted on" + providerName, Toast.LENGTH_SHORT).show();
}
public void onError(SocialAuthError error) {
Log.d("ShareButton" , "Authentication Error");
}
public void onCancel() {
Log.d("ShareButton" , "Authentication Cancelled");
}
}
}
Comments
blog comments powered by Disqus