ASNETutorial [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-ASNETutorial-brightgreen.svg?style=flat)](https://android-arsenal.com/details/3/921) ============ ![](https://raw.githubusercontent.com/gorbin/ASNE/master/resources/recomended.png) Simple example project for https://github.com/gorbin/ASNE library Today social network integration to your android application is common practice - it makes user easily login to your app and share their actions. There are a lot of ways to do it - usually developers add native social network SDK or use API for every network. It provides login via installed social network application or native dialogs. You have to spend time and nerves to learn and use different social network SDKs. What if you need to add one more social network for your application? Sometimes you have to reorganize or redo all your integrations. This leads to idea to create and implement common interface for all social networks. Fortunately there is an open source modular library [ASNE](https://github.com/gorbin/ASNE) that allows you to choose necessary social network and provides full sdk and common interface for most oftenly used requests(login, share, friendslist & etc) It saves your time and simplifies adding another networks in the future. Moreover you can easily add any other social network as new module - the similar way as it's done in other modules. In this tutorial you can learn how easily integrate Facebook, Twitter in android application using [ASNE modules](https://github.com/gorbin/ASNE). This is very basic tutorial with login, sharing link and showing friends list. ##Registering app - getting keys for your application In order to implement Social networks in your application you need keys to make API calls. So register a new social network application and get the keys. Check small tutorial how to get it: - [Facebook](https://github.com/gorbin/ASNE/wiki/Create-Facebook-App) - [Twitter](https://github.com/gorbin/ASNE/wiki/Create-Twitter-App) - [LInkedIn](https://github.com/gorbin/ASNE/wiki/Create-LinkedIn-App) To continue you need - Facebook App ID - Twitter consumer key and consumer secret - LinkedIn consumer key and consumer secret ##Integrating Facebook, Twitter and LinkedIn to your application 1. Create new Project in Android Studio 2. Let's save our social network keys in `values/strings.xml` **strings.xml**(full [source](https://github.com/gorbin/ASNETutorial/blob/master/app/src/main/res/values/strings.xml)) ```xml ASNE-tutorial 1646388738920557 BBQAUAVKYzmYtvEcNhUEvGiKd byZzHPxE1tkGmnPEj5zUyc7MG464Q1LgNRcwbBJV1Ap86575os 75ubsp337ll7sf 8DVk4hi3wvEyzjbh ``` 3. Add permissions and meta data - open `AndroidManifest.xml` file and add uses-permission for INTERNET, ACCESS_NETWORK_STATE and add meta-data for facebook(add appId key) **AndroidManifest.xml**(full [source](https://github.com/gorbin/ASNETutorial/blob/master/app/src/main/AndroidManifest.xml)) ```xml ``` 4. Set dependencies for [asne-modules](https://github.com/gorbin/ASNE): Open _Project Structure_ => choose your module and open _Dependencies_ => _Add new library dependency_ ![add library dependecy](http://i.imgur.com/4k62Ux1.png) Then search for `asne` and add **asne-facebook, asne-twitter, asne-linkedin** ![search asne](http://i.imgur.com/gYou0Uf.png) or just add them manually to `build.gradle` **build.gradle**(full [source](https://github.com/gorbin/ASNETutorial/blob/master/app/build.gradle)) ``` apply plugin: 'com.android.application' android { compileSdkVersion 19 buildToolsVersion '20.0.0' defaultConfig { applicationId "asne_tutorial.githubgorbin.com.asne_tutorial" minSdkVersion 10 targetSdkVersion 19 versionCode 1 versionName "1.0" } buildTypes { release { runProguard false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile 'com.android.support:appcompat-v7:20.0.0' compile 'com.github.asne:asne-facebook:0.2.1' compile 'com.github.asne:asne-linkedin:0.2.1' compile 'com.github.asne:asne-twitter:0.2.1' } ``` 5. Lets create some layouts Just login buttons in main fragment **main_fragment.xml**(full [source](https://github.com/gorbin/ASNETutorial/blob/master/app/src/main/res/layout/main_fragment.xml)) ```xml