0

我正在尝试在我的推特墙上发布链接,就像更新状态或在墙上发布推文一样。

我目前正在使用twitter4j-core-2.1.11.jar库在 twitter 上发布推文,但我也想发布一个带有推文文本的链接。

我该怎么做请帮忙!

4

1 回答 1

6

这可能会帮助你!

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

        //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.TWITTER, R.drawable.twitter);

       //before that import library which is given by socialauth in link given below
        adapter.enable(share);

    }


    /**
     * Listens Response from Library
     * 
     */

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

            // Variable to receive message status

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

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

            adapter.updateStatus("your message|link" + System.currentTimeMillis());
            Toast.makeText(ShareButtonActivity.this, "Message 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");
         }

     }

}

点击这里

于 2012-08-30T07:15:19.087 回答