diff --git a/facebook/README.md b/facebook/README.md index 8b06c9049..fcfc937a5 100644 --- a/facebook/README.md +++ b/facebook/README.md @@ -3,68 +3,22 @@ This open source Java library allows you to integrate Facebook into your Android Getting Started =============== -See our [Android SDK Getting Started Guide](http://developers.facebook.com/docs/guides/mobile#android) +See our [Android SDK Getting Started Guide](https://developers.facebook.com/docs/mobile/android/build/) Sample Applications =============== -This library includes two sample applications to guide you in development. +This library includes three sample applications to guide you in development. * __simple__: A bare-bones app that demonstrates authorization, making API calls, and invoking a dialog. * __stream__: This slightly beefier application lets you view your news feed. -To install a sample application into Eclipse (3.5): +* __Hackbook__: This includes Single Sign On implementation (SSO), sample API calls, and advanced features like Get new Permissions, Run sample FQL Query and Graph API Explorer. Check out [Hackbook for Android](https://developers.facebook.com/docs/mobile/android/hackbook/) -* Create the sample application in your workspace: -2. Select __File__ -> __New__ -> __Project__, choose __Android Project__, and then click __Next__. - 3. Select "Create project from existing source". - 4. Choose either __examples/simple__ or __examples/stream__. You should see the project properties populated. - 5. Click Finish to continue. - -* Build the project: from the Project menu, select "Build Project". - -* Run the application: from the Run menu, select "Run Configurations...". Under Android Application, you can create a new run configuration: give it a name and select the simple Example project; use the default activity Launch Action. See http://developer.android.com/guide/developing/eclipse-adt.html#RunConfig for more details. - - -Testing -=============== - -Here are some tips to help test your application: - -* You will need to have the Facebook application in your test environment. The SDK includes a developer release of the Facebook application that can be side-loaded for testing purposes. On an actual device, you can just download the latest version of the app from the Android Market, but on the emulator you will have to install it yourself: - - adb install FBAndroid.apk - -* Use a signed build. You can sign with a debug key, but make sure that the key you used to sign matches the __Key Hash__ field in the Facebook developer settings. - -* Make sure to test both with and without the Facebook application. The SDK will fall back to a Webview if the Facebook app is not installed. - -* You can use this [guide to developing on a device](http://developer.android.com/guide/developing/device.html). - -Debugging -========== - -Here's a few common errors and their solutions. - -* __Build error: "missing gen files".__ - - This should go away when you rebuild the project. If you have trouble, try running __Clean...__ from the __Project__ menu. - -* __Error: "invalid_key"__ - - This error means that the Facebook server doesn't recognize your Android key hash. Make sure that you correctly generated and copy/pasted your key hash into the Facebook developer settings console (http://www.facebook.com/developers/apps.php), and make sure that your application has been signed with the same key you registered with Facebook. - -* __Dialog won't load or shows a blank screen.__ - - This can be tricky to debug. If the logs don't give an indication of what's wrong, I suggest installing tcpdump on your device and getting a trace. Tutorial: http://www.vbsteven.be/blog/android-debugging-inspectin-network-traffic-with-tcpdump/ - - If you still can't tell what's going on, then file an issue and please include the HTTP trace. - -* __I can't upload photos with photos.upload.__ - - Make sure the Bundle value for the photo parameter is a byte array. Report Issues/Bugs =============== -[http://bugs.developers.facebook.net/enter_bug.cgi?product=SDKs](http://bugs.developers.facebook.net/enter_bug.cgi?product=SDKs) +[Bugs](https://developers.facebook.com/bugs) + +[Questions](http://facebook.stackoverflow.com/questions/tagged/android) diff --git a/facebook/examples/Hackbook/AndroidManifest.xml b/facebook/examples/Hackbook/AndroidManifest.xml new file mode 100644 index 000000000..afd4c5307 --- /dev/null +++ b/facebook/examples/Hackbook/AndroidManifest.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/facebook/examples/Hackbook/README.md b/facebook/examples/Hackbook/README.md new file mode 100644 index 000000000..3036a187e --- /dev/null +++ b/facebook/examples/Hackbook/README.md @@ -0,0 +1,130 @@ +This 'Hackbook for Android' app includes Single Sign On implementation (SSO), sample API calls and Graph API Explorer and is targeted towards android developers who want to make their apps social using Facebook Social Graph. The Code provided here is to showcase how to implement the SSO and make the API calls. If you have any questiosn or comments related to this sample app, please post them here - http://facebook.stackoverflow.com/questions/tagged/hackbook-for-android + +Getting Started +=============== + +See Android tutorial - https://developers.facebook.com/docs/mobile/android/build/ + +Configuring the app +=============== + +1. Launch Eclipse +2. Ensure you have installed the Android plugin. +3. Create Facebook SDK Project - follow the Step-1 instructions in the tutorial +4. Create the Hackbook Project : + 4.1 Select __File__ -> __New__ -> __Project__, choose __Android Project__, and then click __Next__. + 4.2 Select "Create project from existing source". + 4.3. Choose examples/Hackbook. You should see the project properties populated. + 4.4. Click Finish to continue. +5. Add reference to the Facebook SDK - follow the Step-3 instructions in the tutorial +6. Create a Facebook app if you don't have one already and add the app id in the Hackbook.java->APP_ID + +Build the app +=============== + +7. And you are done and ready to compile the project: + 7.1 From the Project menu, select "Build Project". + +Run the app +=============== + +8. Hopefully project would compile fine. Next run the app on the emulator or on the phone (See http://developer.android.com/guide/developing/eclipse-adt.html#RunConfig for more details.) + 8.1 If you plan to run on emulator, ensure you have created an Android Virtual Device (AVD): + 8.1.1 Go to Window -> Android SDK and AVD Manager -> Click New + 8.1.2 Provide a Name (AVD 2.3 e.g.) and choose the Target (Android 2.3 if available). + 8.1.3 Click 'Create AVD' at the bottom and that should create an AVD which you can run the app on described next. + + 8.2 Go to Run->Run Configurations->Android Application->create a new run configuration by clicking the icon with + button on it. + 8.3 Name it 'Hackbook' + 8.4 Under the Project, Browse and choose Hackbook + 8.5 Go to Target tab -> Choose manual if you wish to run on the phone, else choose Automatic and select an AVD created in step 8.1 + 8.6 Click Run and your 'Hackbook for Android' app should be up and running. + + +Installing the Facebook app +=============== + +You will need to have the Facebook application on the handset or the emulator to test the Single Sign On. The SDK includes a developer release of the Facebook application that can be side-loaded for testing purposes. On an actual device, you can just download the latest version of the app from the Android Market, but on the emulator you will have to install it yourself: + + adb install FBAndroid.apk + +What's in there +=============== + +Note: The source tags are provided through out the code base to facilitate easy search for the relevant code. Do a project-wide search for the source tags to get straight to the relevant code. Refer below for source tags for each feature. + +1. Login button - This uses SSO to authorize the app. Clicking on Login should activate SSO (if the app is installed) or show OAuth dialog. When authorizing, no permissions are requested and the app will get basic permission by default. + +Source Tag - login_tag + +- Hackbook.java - this layout the login button and initialize it. Since this is also the calling acitivty, this overrides the onActivityResult() method. +- LoginButton.java - this calls the mFb.authorize(mActivity, mPermissions, mActivityCode, new LoginDialogListener()) which authorizes the app via SSO or OAuth. +- SessionStore.java - stores the access token and access expiry time for future app launch. This is important that you save the access token, else user will need to authorize your app each time they launch it which is annoying and user is likely to churn out. +- SessionEvents.java - Authorization state tracker, calls the listener on login/logout success or error. +------------------------ + +2. Update Status - this allows user to update his status by calling the 'feed' dialog. More info on feed dialog - https://developers.facebook.com/docs/reference/dialogs/feed/ + +Source Tag - update_status_tag, view_post_tag, delete_post_tag + +- Hackbook.java - Case 0: update status by calling the 'feed' dialog. +- UpdateStatusResultDialog.java - shows the object-id returned in the dialog response. You can view or delete the post here. +------------------------ + +3. App Requests - this allows to send app requests to user's friends by calling the 'apprequests' dialog. More info - https://developers.facebook.com/docs/reference/dialogs/requests/ + +Source Tag - app_requests_tag + +- Hackbook.java - Case 1: send the app requests by calling the the 'apprequests' dialog. +------------------------ + +4. Get Friends - Get user's friends via Graph API or FQL Query. User must be logged-in to use this. Also post on a friend's wall by clicking on his name in the list. + +Source Tag - get_friends_tag, friend_wall_tag + +- Hackbook.java - Case 2: Use Graph API 'me/friends' which returns friends sorted by UID, currently it's not possible to sort any other way in the Graph API. Use the FQL Query to sort by name - select name, current_location, uid, pic_square from user where uid in (select uid2 from friend where uid1=me()) order by name +- FriendsList.java - displays the friends profile pic and names as returned by the api. Also post on friend's wall by clicking on the friend. +- FriendsModel.java - run async tasks to fetch the profile picture limited to 15 tasks at any given time. + +5. Upload Photo - Upload a photo either from the media gallery or from a remote server. You require 'photo_upload' to upload photos on user profile. + +Source Tag - upload_photo, view_photo_tag, tag_photo_tag + +- Hackbook.java - Case 3: Photo is uploaded by posting byte-array or url to me/photos endpoint. Media Gallery is launched by invoking the MediaStore.Images.Media.EXTERNAL_CONTENT_URI intent and overriding the OnActivityResult() to get the picture from the media gallery. Photo from remote server is uploaded by simply providing the image url in the 'url' param in the graph.facebook.com/me/photos endpoint. +- UploadPhotoResultDialog.java - shows the object-id returned after uploaded the photo. You can view or tag the photo here. +------------------------ + + +6. Place Check-in - Fetch user's current location or use Times Square as the current location and get nearby places which user can check-in at. + +Source Tag - fetch_places_tag, check_in_tag + +- Hackbook.java - Case 4: Ask to fetch current location or use Times Square as the current location. +- Places.java - Get user's current location and fetch the nearby places by calling the graph.facebook.com/search?type=places&distance=1000¢er=lat,lon. Check-in user at a place by calling the graph.facebook.com/me/checkins&place=&message=&coordinates={"latitude": , "longitude:": } +------------------------ + +7. Run FQL Query - Type and run any FQL Query and see the results. + +Source Tag - fql_query_tag + +- FQLQuery.java - Layout the FQL Query Dialog and run the query and show the results. +------------------------ + +8. Graph API Explorer - Explore user's social graph, see his and friends' connections and get new permissions. This is similar to the Graph Explorer dev tool - http://developers.facebook.com/tools/explorer/. The ObjectIDs in the API response are linkified and can be clicked to fetch object specific data. + - Click the 'x' button to clear the textfield + - Click the green up arrow button in the textfield to get the 'me' object data. + - Click on 'Get Permissions' to get new permissions including user's, his friends or extended permissions. + - Click on 'Fields/Connections' to see current object's fields and connections. + - On the Fields & Connections dialog, in the Fields tab, select the fields to view or in the Connections tab, click the connection to view it's content. + +Source Tag - graph_explorer + +- Hackbook.java - Case 5: Launch the GraphExplorer intent +- GraphExplorer.java - Layout and execute the graph explorer +- IntentUriHandler.java - Handle the fbgraphex: schema generated while linkifying the Object IDs in the graph explorer output + + + +Report Issues/Bugs +=============== +Please report issues here - http://facebook.stackoverflow.com/questions/tagged/hackbook-for-android diff --git a/facebook/examples/Hackbook/default.properties b/facebook/examples/Hackbook/default.properties new file mode 100644 index 000000000..6805fb9fe --- /dev/null +++ b/facebook/examples/Hackbook/default.properties @@ -0,0 +1,14 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "build.properties", and override values to adapt the script to your +# project structure. + +# Indicates whether an apk should be generated for each density. +split.density=false +# Project target. +target=android-8 +android.library.reference.1=../../../newdialog/facebook-android-sdk/facebook diff --git a/facebook/examples/Hackbook/res/drawable-hdpi/splash.png b/facebook/examples/Hackbook/res/drawable-hdpi/splash.png new file mode 100644 index 000000000..3efb5e80a Binary files /dev/null and b/facebook/examples/Hackbook/res/drawable-hdpi/splash.png differ diff --git a/facebook/examples/Hackbook/res/drawable/icon.png b/facebook/examples/Hackbook/res/drawable/icon.png new file mode 100644 index 000000000..7a2d0cbe4 Binary files /dev/null and b/facebook/examples/Hackbook/res/drawable/icon.png differ diff --git a/facebook/examples/Hackbook/res/drawable/icon_hack.png b/facebook/examples/Hackbook/res/drawable/icon_hack.png new file mode 100644 index 000000000..a812187e6 Binary files /dev/null and b/facebook/examples/Hackbook/res/drawable/icon_hack.png differ diff --git a/facebook/examples/Hackbook/res/drawable/login.png b/facebook/examples/Hackbook/res/drawable/login.png new file mode 100644 index 000000000..95c8dc156 Binary files /dev/null and b/facebook/examples/Hackbook/res/drawable/login.png differ diff --git a/facebook/examples/Hackbook/res/drawable/login_button.xml b/facebook/examples/Hackbook/res/drawable/login_button.xml new file mode 100644 index 000000000..73dc6c3ab --- /dev/null +++ b/facebook/examples/Hackbook/res/drawable/login_button.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/facebook/examples/Hackbook/res/drawable/login_down.png b/facebook/examples/Hackbook/res/drawable/login_down.png new file mode 100644 index 000000000..10d216b3f Binary files /dev/null and b/facebook/examples/Hackbook/res/drawable/login_down.png differ diff --git a/facebook/examples/Hackbook/res/drawable/logout.png b/facebook/examples/Hackbook/res/drawable/logout.png new file mode 100644 index 000000000..290272aa0 Binary files /dev/null and b/facebook/examples/Hackbook/res/drawable/logout.png differ diff --git a/facebook/examples/Hackbook/res/drawable/logout_button.xml b/facebook/examples/Hackbook/res/drawable/logout_button.xml new file mode 100644 index 000000000..58f57656b --- /dev/null +++ b/facebook/examples/Hackbook/res/drawable/logout_button.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/facebook/examples/Hackbook/res/drawable/logout_down.png b/facebook/examples/Hackbook/res/drawable/logout_down.png new file mode 100644 index 000000000..1ab14b9dc Binary files /dev/null and b/facebook/examples/Hackbook/res/drawable/logout_down.png differ diff --git a/facebook/examples/Hackbook/res/drawable/me.png b/facebook/examples/Hackbook/res/drawable/me.png new file mode 100644 index 000000000..413e20bb9 Binary files /dev/null and b/facebook/examples/Hackbook/res/drawable/me.png differ diff --git a/facebook/examples/Hackbook/res/drawable/splash.png b/facebook/examples/Hackbook/res/drawable/splash.png new file mode 100644 index 000000000..1892fcec6 Binary files /dev/null and b/facebook/examples/Hackbook/res/drawable/splash.png differ diff --git a/facebook/examples/Hackbook/res/drawable/x.png b/facebook/examples/Hackbook/res/drawable/x.png new file mode 100644 index 000000000..f0978141d Binary files /dev/null and b/facebook/examples/Hackbook/res/drawable/x.png differ diff --git a/facebook/examples/Hackbook/res/layout/connection_item.xml b/facebook/examples/Hackbook/res/layout/connection_item.xml new file mode 100644 index 000000000..e556c0685 --- /dev/null +++ b/facebook/examples/Hackbook/res/layout/connection_item.xml @@ -0,0 +1,11 @@ + + + diff --git a/facebook/examples/Hackbook/res/layout/fields_connections_list.xml b/facebook/examples/Hackbook/res/layout/fields_connections_list.xml new file mode 100644 index 000000000..06b48f89e --- /dev/null +++ b/facebook/examples/Hackbook/res/layout/fields_connections_list.xml @@ -0,0 +1,45 @@ + + + + + + + +