[英]Post a link on twitter wall?
我正試圖在Twitter牆上張貼一個鏈接,就像更新狀態一樣,或者在牆上張貼一條推文。
我目前正在使用twitter4j-core-2.1.11.jar庫在Twitter上發布推文,但我也想發布帶有推文文本的鏈接。
我該怎么辦,請幫忙!
這可能對您有幫助!
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");
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.