/ Published in: Java
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
the api will open dialog of providers. User can access the provider from dialog
and can update the status , get friends list , user profile
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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 share.setText("Share"); share.setBackgroundResource(R.drawable.button_gradient); // Add it to Library adapter = new SocialAuthAdapter(new ResponseListener()); // Add providers 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 Log.d("ShareButton", "Provider Name = " + providerName); try { // Please avoid sending duplicate message. Social Media Providers block duplicate messages. status = true; } { 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"); } } }
URL: http://code.google.com/p/socialauth-android/