如何更新Social Auth share Android中的状态

时间:2013-02-12 18:11:52

标签: android facebook twitter share linkedin

我正在使用Social Auth社交网络集成来整合facebook,twitter和linkedin。但是,在社交网站中发布的更新状态是以编程方式硬编码的。

由于我是Android编程的新手,有人会帮助我........

我需要更新状态功能的代码....例如。当我点击Facebook时,它应该询问我要更新的状态,然后在相应的社交网络中发布该消息

我的代码如下

     package org.brickred.socialbar;

      import org.brickred.socialauth.android.DialogListener;
      import org.brickred.socialauth.android.SocialAuthError;
      import org.brickred.socialauth.android.SocialAuthAdapter;
      import org.brickred.socialauth.android.SocialAuthAdapter.Provider;

      import android.app.Activity;
      import android.os.Bundle;
      import android.util.Log;
      import android.widget.LinearLayout;
      import android.widget.TextView;
      import android.widget.Toast;



public class ShareBarActivity extends Activity {

// SocialAuth Component
SocialAuthAdapter adapter;
boolean status;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);



    LinearLayout bar = (LinearLayout)findViewById(R.id.linearbar);


    // Add Bar 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.enable(bar);

    // Set Size of Dialog
    adapter.setDialogSize(30,60);
}


/**
 * Listens Response from Library
 * 
 */

private final class ResponseListener implements DialogListener 
{
    public void onComplete(Bundle values) {

        // Variable to receive message status


        Log.d("ShareBar" , "Authentication Successful");

        // Get name of provider after authentication
        String providerName = values.getString(SocialAuthAdapter.PROVIDER);
        Log.d("ShareBar", "Provider Name = " + providerName);

        // Please avoid sending duplicate message. Social Media Providers block duplicate messages.
        adapter.updateStatus("test API");   

        Toast.makeText(ShareBarActivity.this, "Message posted on " + providerName, Toast.LENGTH_SHORT).show();  
     }

     public void onError(SocialAuthError error) {
        error.printStackTrace();
        Log.d("ShareBar" , error.getMessage());
     }

     public void onCancel() {
        Log.d("ShareBar" , "Authentication Cancelled");
     }

 }

}

0 个答案:

没有答案