com.drismo.facebook
Class ShareOnFacebook

java.lang.Object
  extended by android.content.Context
      extended by android.content.ContextWrapper
          extended by android.view.ContextThemeWrapper
              extended by android.app.Activity
                  extended by com.drismo.facebook.ShareOnFacebook
All Implemented Interfaces:
android.content.ComponentCallbacks, android.view.KeyEvent.Callback, android.view.LayoutInflater.Factory, android.view.View.OnCreateContextMenuListener, android.view.Window.Callback

public class ShareOnFacebook
extends android.app.Activity

This activity uses the Android Facebook SDK to share a link to Facebook via a Facebook application.
To specify string to share, use putExtra("facebookMessage", "this is the message");


Nested Class Summary
(package private)  class ShareOnFacebook.LoginDialogListener
          Listen to events from the Facebook.DialogListener, and give the user relevant feedback.
private  class ShareOnFacebook.UploadToFacebook
          Upload the content to Facebook, and finish all Facebook dialogs when finished.
(package private)  class ShareOnFacebook.WallPostDialogListener
          Listen to events from the Facebook.DialogListener, and give the user relevant feedback.
 
Field Summary
private static java.lang.String APP_ID
           
private static java.lang.String EXPIRES
           
private  Facebook facebook
           
private static java.lang.String KEY
           
private  java.lang.String messageToPost
           
private static java.lang.String[] PERMISSIONS
           
private  boolean shareImage
           
private static java.lang.String TOKEN
           
 
Fields inherited from class android.app.Activity
DEFAULT_KEYS_DIALER, DEFAULT_KEYS_DISABLE, DEFAULT_KEYS_SEARCH_GLOBAL, DEFAULT_KEYS_SEARCH_LOCAL, DEFAULT_KEYS_SHORTCUT, FOCUSED_STATE_SET, RESULT_CANCELED, RESULT_FIRST_USER, RESULT_OK
 
Fields inherited from class android.content.Context
ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, AUDIO_SERVICE, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_NOT_FOREGROUND, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, DEVICE_POLICY_SERVICE, DROPBOX_SERVICE, INPUT_METHOD_SERVICE, KEYGUARD_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MODE_APPEND, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NOTIFICATION_SERVICE, POWER_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, TELEPHONY_SERVICE, UI_MODE_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_SERVICE, WINDOW_SERVICE
 
Constructor Summary
ShareOnFacebook()
           
 
Method Summary
 void doNotShare(android.view.View button)
          Nothing to be done.
 void loginAndPostToWall()
          Log on to Facebook.
protected  void onCreate(android.os.Bundle savedInstanceState)
          Lock the screen orientation, manage received trip data and prompt the user to share.
 void postToWall(java.lang.String message)
          Post the trip summary to the Facebook wall.
 boolean restoreCredentials(Facebook facebook)
          Get the user's current Facebook login information, from our application preferences.
 boolean saveCredentials(Facebook facebook)
          Storing Facebook login data to our (hidden) application preferences.
 void share(android.view.View button)
          Share the trip.
private  void showToast(java.lang.String message)
          Post a short Toast.
 
Methods inherited from class android.app.Activity
addContentView, closeContextMenu, closeOptionsMenu, createPendingResult, dismissDialog, dispatchKeyEvent, dispatchPopulateAccessibilityEvent, dispatchTouchEvent, dispatchTrackballEvent, findViewById, finish, finishActivity, finishActivityFromChild, finishFromChild, getApplication, getCallingActivity, getCallingPackage, getChangingConfigurations, getComponentName, getCurrentFocus, getInstanceCount, getIntent, getLastNonConfigurationInstance, getLayoutInflater, getLocalClassName, getMenuInflater, getParent, getPreferences, getRequestedOrientation, getSystemService, getTaskId, getTitle, getTitleColor, getVolumeControlStream, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, getWindow, getWindowManager, hasWindowFocus, isChild, isFinishing, isTaskRoot, managedQuery, moveTaskToBack, onActivityResult, onApplyThemeResource, onAttachedToWindow, onBackPressed, onChildTitleChanged, onConfigurationChanged, onContentChanged, onContextItemSelected, onContextMenuClosed, onCreateContextMenu, onCreateDescription, onCreateDialog, onCreateDialog, onCreateOptionsMenu, onCreatePanelMenu, onCreatePanelView, onCreateThumbnail, onCreateView, onDestroy, onDetachedFromWindow, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyUp, onLowMemory, onMenuItemSelected, onMenuOpened, onNewIntent, onOptionsItemSelected, onOptionsMenuClosed, onPanelClosed, onPause, onPostCreate, onPostResume, onPrepareDialog, onPrepareDialog, onPrepareOptionsMenu, onPreparePanel, onRestart, onRestoreInstanceState, onResume, onRetainNonConfigurationInstance, onSaveInstanceState, onSearchRequested, onStart, onStop, onTitleChanged, onTouchEvent, onTrackballEvent, onUserInteraction, onUserLeaveHint, onWindowAttributesChanged, onWindowFocusChanged, openContextMenu, openOptionsMenu, overridePendingTransition, registerForContextMenu, removeDialog, requestWindowFeature, runOnUiThread, setContentView, setContentView, setContentView, setDefaultKeyMode, setFeatureDrawable, setFeatureDrawableAlpha, setFeatureDrawableResource, setFeatureDrawableUri, setIntent, setPersistent, setProgress, setProgressBarIndeterminate, setProgressBarIndeterminateVisibility, setProgressBarVisibility, setRequestedOrientation, setResult, setResult, setSecondaryProgress, setTitle, setTitle, setTitleColor, setVisible, setVolumeControlStream, showDialog, showDialog, startActivity, startActivityForResult, startActivityFromChild, startActivityIfNeeded, startIntentSender, startIntentSenderForResult, startIntentSenderFromChild, startManagingCursor, startNextMatchingActivity, startSearch, stopManagingCursor, takeKeyEvents, triggerSearch, unregisterForContextMenu
 
Methods inherited from class android.view.ContextThemeWrapper
attachBaseContext, getTheme, setTheme
 
Methods inherited from class android.content.ContextWrapper
bindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkUriPermission, checkUriPermission, clearWallpaper, createPackageContext, databaseList, deleteDatabase, deleteFile, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getCacheDir, getClassLoader, getContentResolver, getDatabasePath, getDir, getExternalCacheDir, getExternalFilesDir, getFilesDir, getFileStreamPath, getMainLooper, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getResources, getSharedPreferences, getWallpaper, grantUriPermission, isRestricted, openFileInput, openFileOutput, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, removeStickyBroadcast, revokeUriPermission, sendBroadcast, sendBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendStickyBroadcast, sendStickyOrderedBroadcast, setWallpaper, setWallpaper, startInstrumentation, startService, stopService, unbindService, unregisterReceiver
 
Methods inherited from class android.content.Context
getString, getString, getText, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

APP_ID

private static final java.lang.String APP_ID
See Also:
Constant Field Values

PERMISSIONS

private static final java.lang.String[] PERMISSIONS

TOKEN

private static final java.lang.String TOKEN
See Also:
Constant Field Values

EXPIRES

private static final java.lang.String EXPIRES
See Also:
Constant Field Values

KEY

private static final java.lang.String KEY
See Also:
Constant Field Values

facebook

private Facebook facebook

messageToPost

private java.lang.String messageToPost

shareImage

private boolean shareImage
Constructor Detail

ShareOnFacebook

public ShareOnFacebook()
Method Detail

saveCredentials

public boolean saveCredentials(Facebook facebook)
Storing Facebook login data to our (hidden) application preferences.

Parameters:
facebook - A Facebook object, from the facebook-android-sdk.
Returns:
True if it was stored successfully. False otherwise.

restoreCredentials

public boolean restoreCredentials(Facebook facebook)
Get the user's current Facebook login information, from our application preferences.

Parameters:
facebook - A Facebook object, from the facebook-android-sdk.
Returns:
True if the user don't have to log in again. False if no valid session exists.

onCreate

protected void onCreate(android.os.Bundle savedInstanceState)
Lock the screen orientation, manage received trip data and prompt the user to share.

Overrides:
onCreate in class android.app.Activity
Parameters:
savedInstanceState - Not beeing used, as onSaveInstanceState(Bundle) is not implemented.

doNotShare

public void doNotShare(android.view.View button)
Nothing to be done. Closing the Facebook sharing dialog.

Parameters:
button - button

share

public void share(android.view.View button)
Share the trip. Log in first if necessary.

Parameters:
button - button

loginAndPostToWall

public void loginAndPostToWall()
Log on to Facebook.


postToWall

public void postToWall(java.lang.String message)
Post the trip summary to the Facebook wall. Attach a picture or link based on where in the app the sharing is done from.

Parameters:
message - The text summary of the trip.

showToast

private void showToast(java.lang.String message)
Post a short Toast.

Parameters:
message - The message to show.