【将LinkedinFacebookTwitterMySpace集成到Android应用程序中】春衣少年当酒歌,起舞四顾以笑和。这篇文章主要讲述将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
- 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( " Welcome to SocialAuth Demo. We are sharing text SocialAuth android by share button." ) ;
- //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.FACEBOOK, R.drawable.facebook) ;
- adapter.addProvider( Provider.TWITTER, R.drawable.twitter) ;
- adapter.addProvider( Provider.LINKEDIN, R.drawable.linkedin) ;
- adapter.addProvider( Provider.MYSPACE, R.drawable.myspace) ;
- adapter.enable( share) ;
- }
- /**
- * Listens Response from Library
- *
- */
- private final class ResponseListener implements DialogListener
- {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- public void onComplete( Bundle values) {
- // Variable to receive message status
- boolean status;
- Log.d( " ShareButton" , " Authentication Successful" ) ;
- // Get name of provider after authentication
- String providerName = values.getString( SocialAuthAdapter.PROVIDER) ;
- Log.d( " ShareButton" , " Provider Name = " + providerName) ;
- try
- {
- // Please avoid sending duplicate message. Social Media Providers block duplicate messages.
- adapter.getCurrentProvider( ) .updateStatus( " SocialAuth Android" + System.currentTimeMillis( ) ) ;
- status = true;
- }
- catch ( Exception e)
- {
- status = false;
- }
- // Post Toast or Dialog to display on screen
- if( status)
- Toast.makeText( ShareButtonActivity.this, " Message posted on " + providerName, Toast.LENGTH_SHORT) .show( ) ;
- else
- Toast.makeText( ShareButtonActivity.this, " Message not 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" ) ;
- }
- }
- }
推荐阅读
- 使用dd-plist的Android plist解析器
- android plist解析器
- android Plist解析器xml资产
- Android MyOverlay扩展覆盖
- Android和Iphone-现代css媒体查询
- .NET-C#-Interop-Excel-Utility/Wrapper类
- Appindicator正面
- 使用AppleScript重新启动Django开发服务器
- 用于检测访问者是否在android设备上的函数