How to integrate facebook, twitter and google plus to an android app

后端 未结 4 1229
醉梦人生
醉梦人生 2020-12-29 11:08

I like to integrate Facebook, twitter and Google plus to my app, so that using the app, user can update their status. Therefore I like to know how this can be done.

相关标签:
4条回答
  • 2020-12-29 11:29

    As for facebook and twitter, you can do this through their API. For facebook, fortunately they have provide android developer with facebook sdk for android, example included on the SDK.

    And for Twitter you can use external libraries as written on twitter developer docs, and there is a library called Twitter4J that is android ready.

    Unfortunately Google Plus API are not available yet.

    0 讨论(0)
  • 2020-12-29 11:51

    In your app you can use Fabric IDE plugins to integrate your app with twitter. With Fabric you can integrate twitter in simple steps The Fabric IDE plugins will automatically create and configure a Twitter application when you use it to integrate the Twitter Kit into your app. You can read related documentation on below link- https://docs.fabric.io/android/index.html

    0 讨论(0)
  • 2020-12-29 11:55

    I would highly recommend not to use those SDK since they contain a lot of bugs, and are not very reliable as far as I've seen.

    If you just want to share simple text from your app to Facebook or Twitter and so on... I would recommend to create a chooser to let the user pick which app from his phone he wants to user for sharing. It is simpler, more reliable and more the 'android way' of doing it.

    Here is the code that you have to write :

    Intent shareIntent=new Intent(Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT,"I want to share this with you!");
    shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Great Post");
    startActivity(Intent.createChooser(shareIntent, "Share..."));
    
    0 讨论(0)
  • 2020-12-29 11:56

    Now you can try this library: https://github.com/antonkrasov/AndroidSocialNetworks

    It's very easy to use:

    mSocialNetworkManager = (SocialNetworkManager) getFragmentManager().findFragmentByTag(SOCIAL_NETWORK_TAG);
    
    if (mSocialNetworkManager == null) {
        mSocialNetworkManager = SocialNetworkManager.Builder.from(getActivity())
                .twitter(<< TWITTER  API TOKEN  >>, << TWITTER  API SECRET  >>)
                .linkedIn(<< LINKED_IN  API TOKEN  >>, << LINKED_IN API TOKEN  >>, "r_basicprofile+rw_nus+r_network+w_messages")
                .facebook()
                .googlePlus()
                .build();
        getFragmentManager().beginTransaction().add(mSocialNetworkManager, SOCIAL_NETWORK_TAG).commit();
    }
    

    ...

    mSocialNetworkManager.getTwitterSocialNetwork().requestLogin(new OnLoginCompleteListener() {
        @Override
        public void onLoginSuccess(int socialNetworkID) {
    
        }
    
        @Override
        public void onError(int socialNetworkID, String requestID, String errorMessage, Object data) {
    
        }
    });
    
    0 讨论(0)
提交回复
热议问题