Skip to content
Gorbin edited this page Aug 26, 2014 · 1 revision

Getting started

Adding library

1) Using Maven Central

Add dependency for choosen module, here example for all modules, you can choose one or two

dependencies {
...
    compile 'com.github.asne:asne-facebook:0.2.0'
	compile 'com.github.asne:asne-twitter:0.2.0'
    compile 'com.github.asne:asne-googleplus:0.2.0'
    compile 'com.github.asne:asne-linkedin:0.2.0'
	compile 'com.github.asne:asne-vk:0.2.0'
    compile 'com.github.asne:asne-odnoklassniki:0.2.0'
...
}

2) Import module to your project

For example, in AndroidStudio you can add modules via Gradle:

  1. Copy social module to your project.
  2. In settings.gradle include ':ASNECore', ':socialNetworkModuleName'
  3. In build.gradle of your app (YOUR_PROJECT/app/build.gradle) add new dependencies: compile project(':socialNetworkModuleName')

Without Gradle, add ASNE like:

  1. Open Project Settings and choose Modules.
  2. Find button "Add" (+), and choose Import module
  3. Find ASNECore and socialNetworkModuleName directories - «Add».
  4. Choose Create module from existing sources, then click "Next" rename module from "main" to "ASNECore".
  5. Add new asne-module in dependencies to your app.

Using library

Firstly, you need to create app in social network. You can read about main steps:

Second, you need to initialize mSocialNetworkManager, it contain common interface for all ASNE social network modules. Initialize chosen social network and add social network to SocialNetworkManager(example: FacebookSocialNetwork):

mSocialNetworkManager = (SocialNetworkManager) getFragmentManager().findFragmentByTag(SOCIAL_NETWORK_TAG);
	if (mSocialNetworkManager == null) {
        mSocialNetworkManager = new SocialNetworkManager();
		FacebookSocialNetwork fbNetwork = new FacebookSocialNetwork(this, fbScope);
        mSocialNetworkManager.addSocialNetwork(fbNetwork);
        getFragmentManager().beginTransaction().add(mSocialNetworkManager, SOCIAL_NETWORK_TAG).commit();
	}

where fbScope is permissions for your app, for example I used:

ArrayList<String> fbScope = new ArrayList<String>();
fbScope.addAll(Arrays.asList("public_profile, email, user_friends, user_location, user_birthday"));

Then you can send requests to social network like:

   mSocialNetworkManager.getVKSocialNetwork().requestLogin(new OnLoginCompleteListener() {
       @Override
       public void onLoginSuccess(int socialNetworkID) {

       }

       @Override
       public void onError(int socialNetworkID, String requestID, String errorMessage, Object data) {

       }
   });

Or get Social network directly like:

	Session session = Session.getActiveSession();

Important

If you want to use Google Plus, add this to your MainActivity:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    /**
     * This is required only if you are using Google Plus, the issue is that there SDK
     * require Activity to launch Auth, so library can't receive onActivityResult in fragment
     */
    Fragment fragment = getSupportFragmentManager().findFragmentByTag(BaseDemoFragment.SOCIAL_NETWORK_TAG);
    if (fragment != null) {
            fragment.onActivityResult(requestCode, resultCode, data);
        }
    }

Facebook Upgrades

Facebook some permissions you can get only after Facebook submission, so my demo app wasn't submitted due low functionality. So if you want to use it with all functionality send me your facebook id and I add you as tester - this is easy way to to fully use demo app email: gorbin.e.o@gmail.com

Apps are no longer able to retrieve the full list of a user's friends (only those friends who have specifically authorized your app using the user_friends permission) but if you add me as friend you will see me in friendlist([profile][6])