将LinkedinFacebookTwitterMySpace集成到Android应用程序中

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了将LinkedinFacebookTwitterMySpace集成到Android应用程序中相关的知识,希望对你有一定的参考价值。

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
  1. public class ShareButtonActivity extends Activity {
  2.  
  3. // SocialAuth Component
  4. SocialAuthAdapter adapter;
  5.  
  6. @Override
  7. public void onCreate(Bundle savedInstanceState) {
  8. super.onCreate(savedInstanceState);
  9. setContentView(R.layout.main);
  10.  
  11. // Welcome Message
  12. TextView textview = (TextView)findViewById(R.id.text);
  13. textview.setText("Welcome to SocialAuth Demo. We are sharing text SocialAuth android by share button.");
  14.  
  15. //Create Your Own Share Button
  16. Button share = (Button)findViewById(R.id.sharebutton);
  17. share.setText("Share");
  18. share.setTextColor(Color.WHITE);
  19. share.setBackgroundResource(R.drawable.button_gradient);
  20.  
  21. // Add it to Library
  22. adapter = new SocialAuthAdapter(new ResponseListener());
  23.  
  24. // Add providers
  25. adapter.addProvider(Provider.FACEBOOK, R.drawable.facebook);
  26. adapter.addProvider(Provider.TWITTER, R.drawable.twitter);
  27. adapter.addProvider(Provider.LINKEDIN, R.drawable.linkedin);
  28. adapter.addProvider(Provider.MYSPACE, R.drawable.myspace);
  29. adapter.enable(share);
  30.  
  31. }
  32.  
  33.  
  34. /**
  35. * Listens Response from Library
  36. *
  37. */
  38.  
  39. private final class ResponseListener implements DialogListener
  40. {
  41. /**
  42. *
  43. */
  44. private static final long serialVersionUID = 1L;
  45.  
  46. public void onComplete(Bundle values) {
  47.  
  48. // Variable to receive message status
  49. boolean status;
  50.  
  51. Log.d("ShareButton" , "Authentication Successful");
  52.  
  53. // Get name of provider after authentication
  54. String providerName = values.getString(SocialAuthAdapter.PROVIDER);
  55. Log.d("ShareButton", "Provider Name = " + providerName);
  56.  
  57. try
  58. {
  59. // Please avoid sending duplicate message. Social Media Providers block duplicate messages.
  60. adapter.getCurrentProvider().updateStatus("SocialAuth Android" + System.currentTimeMillis());
  61. status = true;
  62. }
  63. catch (Exception e)
  64. {
  65. status = false;
  66. }
  67.  
  68. // Post Toast or Dialog to display on screen
  69. if(status)
  70. Toast.makeText(ShareButtonActivity.this, "Message posted on " + providerName, Toast.LENGTH_SHORT).show();
  71. else
  72. Toast.makeText(ShareButtonActivity.this, "Message not posted on" + providerName, Toast.LENGTH_SHORT).show();
  73.  
  74. }
  75.  
  76. public void onError(SocialAuthError error) {
  77. Log.d("ShareButton" , "Authentication Error");
  78. }
  79.  
  80. public void onCancel() {
  81. Log.d("ShareButton" , "Authentication Cancelled");
  82. }
  83.  
  84. }
  85.  
  86. }

以上是关于将LinkedinFacebookTwitterMySpace集成到Android应用程序中的主要内容,如果未能解决你的问题,请参考以下文章

如何将Ios文件上传到

Javascript 将正则表达式 \\n 替换为 \n,将 \\t 替换为 \t,将 \\r 替换为 \r 等等

如何将视频文件转换格式

sh 一个将生成CA的脚本,将CA导入到钥匙串中,然后它将创建一个证书并与CA签名,然后将其导入到

python怎么将0写入文件?

如何将CMD窗口背景改成透明?