Git Product home page Git Product logo

facebookimageshareintent's Introduction

FacebookImageShareIntent

An Android share intent that allows you to share and image with text aswell!

Using the Facebook SDK 3.14.1

This is a work around for this bug https://developers.facebook.com/bugs/332619626816423

How to Use

1 Change the app_id in strings.xml (You will find this at https://developers.facebook.com/ under dashboard in your facebook app) e.g. if your app_id was 123456789123456

<!--LIVE APP ID-->
<string name="app_id">123456789123456</string>

Adding to your own app

  1. Copy FacebookShareActivty to your project
  2. Import your R file from your project
import com.YOURAPPPACKAGENAME.app.R;
  1. Copy activity_facebook_share.xml from res/layout into res/layout in your project.

  2. Add the Facebook SDK

  3. The 'import module' does not work properly in Android Studio So this is the way I do it

  4. Copy the 'facebook' module from this project.

  5. Edit the settings.gradle in the root project

  6. add the facebook module in here like so

      include ':app', ':facebook'
  7. Go to file > Project Structure

  8. click on your app module > Dependecies tab > '+' button at the bottom > Module Dependecy > then click on ':facebook'

  9. Add these strings to your strings.xml

    <!--Facebook share intent Strings-->
     <string name="title_activity_facebook_share">Facebook</string>
     <string name="facebook_default_text">Please enter your text here</string>
     <string name="title_post_text">Write Post</string>
     <string name="post_button_text">Post</string>
     <string name="title_facebook_login">Facebook Login</string>
    
    
     <!--LIVE APP ID-->
     <string name="app_id">ADD_YOUR_OWN_APP_ID_HERE</string>
     <string name="facebook_post_content_desc">Image to share</string>
     <string name="app_package_name">com.YOURAPPPACKAGENAME.app</string>
  10. Add this activity and meta-data to your AndroidMaifest.xml

    <activity
             android:name="com.CHANGETHISTOYOURAPP.app.FacebookShareActivity"
             android:label="@string/title_activity_facebook_share"
             android:icon="@drawable/icon_facebook_activity"
             android:theme="@style/FullscreenTheme">
             <!--Using icon from facebook app as of 23/05/14-->
             <intent-filter>
                 <action android:name="android.intent.action.SEND"/>
                 <category android:name="android.intent.category.DEFAULT"/>
                 <data android:mimeType="text/plain"/>
                 <data android:mimeType="image/*"/>
             </intent-filter>
         </activity>
         <activity
             android:name="com.facebook.LoginActivity"
             android:label="@string/title_facebook_login" >
         </activity>
         <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id"/>
  11. Add these styles to styles.xml

    <style name="FullscreenTheme" parent="android:Theme.NoTitleBar">
         <item name="android:windowContentOverlay">@null</item>
         <item name="android:windowBackground">@null</item>
     </style>
    
     <!-- Base application theme. -->
     <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
         <!-- Customize your theme here. -->
     </style>
  12. Add the Facebook Icon under res/drawable/icon_facebook_activity.png to your res/drawable folder

  13. Clean the build, then rebuild.

  14. Change these settings in https://developers.facebook.com/ under settings

  15. Package Name to your pack name of your app e.g. com.weeworld.facebooktestingimageandtext.app

  16. Class Name to your main activity e.g. MainActivity

  17. Add the Key Hashes (you can get this by running the app with 'getHashKey()' uncommented and checking the log or on OS X, run:

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64 ```

To use the intent

The Intent supports the type "image/*" and "text/plain" so as long as you set the type of your intent when creating the chooser it will show. If you would rather have a set list of intents check out the demo app to see how that is done in 'shareButtonPressed' in 'MainActivity.java'

Make sure the extra stream is set to the uri of the image and extra text is the caption, for local images check the demo app.

intent.putExtra(Intent.EXTRA_TEXT, "picture caption #test");
intent.putExtra(Intent.EXTRA_STREAM, path);

If you get CLOSED_LOGIN_FAILED sessions check your setting in https://developers.facebook.com/ ScreenShots

screenshot1

facebookimageshareintent's People

Contributors

b099l3 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.