2

我正在使用 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");
     }

 }

}

4

0 回答 0