I am new to android development plz can any body help me in getting facebook integration in app.public class Facebook { @Deprecated\[code\]public static final String REDIRECT_URI = "fbconnect://success";@Deprecatedpublic static final String CANCEL_URI = "fbconnect://cancel";@Deprecatedpublic static final String TOKEN = "access_token";@Deprecatedpublic static final String EXPIRES = "expires_in";@Deprecatedpublic static final String SINGLE_SIGN_ON_DISABLED = "service_disabled";@Deprecatedpublic static final Uri ATTRIBUTION_ID_CONTENT_URI = Uri.parse("content://com.facebook.katana.provider.AttributionIdProvider");@Deprecatedpublic static final String ATTRIBUTION_ID_COLUMN_NAME = "aid";@Deprecatedpublic static final int FORCE_DIALOG_AUTH = -1;private static final String LOGIN = "oauth";// Used as default activityCode by authorize(). See authorize() below.private static final int DEFAULT_AUTH_ACTIVITY_CODE = 32665;// Facebook server endpoints: may be modified in a subclass for testing@Deprecatedprotected static String DIALOG_BASE_URL = "https://m.facebook.com/dialog/";@Deprecatedprotected static String GRAPH_BASE_URL = "https://graph.facebook.com/";@Deprecatedprotected static String RESTSERVER_URL = "https://api.facebook.com/restserver.php";private final Object lock = new Object();private String accessToken = null;private long accessExpiresMillisecondsAfterEpoch = 0;private long lastAccessUpdateMillisecondsAfterEpoch = 0;private String mAppId;private Activity pendingAuthorizationActivity;private String[] pendingAuthorizationPermissions;private Session pendingOpeningSession;private volatile Session session; // must synchronize this.sync to writeprivate boolean sessionInvalidated; // must synchronize this.sync to accessprivate SetterTokenCache tokenCache;private volatile Session userSetSession;// If the last time we extended the access token was more than 24 hours ago// we try to refresh the access token again.final private long REFRESH_TOKEN_BARRIER = 24L * 60L * 60L * 1000L;private boolean shouldAutoPublishInstall = true;@Deprecatedpublic Facebook(String appId) { if (appId == null) { throw new IllegalArgumentException("You must specify your application ID when \[/code\]instantiating "\[code\] + "a Facebook object. See README for details."); } mAppId = appId;}@Deprecatedpublic void authorize(Activity activity, final DialogListener listener) { authorize(activity, new String[]{}, DEFAULT_AUTH_ACTIVITY_CODE, \[/code\]SessionLoginBehavior.SSO_WITH_FALLBACK,\[code\] listener);}\[/code\]@Deprecated public void authorize(Activity activity, String[] permissions, final DialogListenerlistener) {\[code\] authorize(activity, permissions, DEFAULT_AUTH_ACTIVITY_CODE, \[/code\]SessionLoginBehavior.SSO_WITH_FALLBACK, listener);\[code\]}@Deprecatedpublic void authorize(Activity activity, String[] permissions, int activityCode, final\[/code\]DialogListener listener) {\[code\] SessionLoginBehavior behavior = (activityCode >= 0) ? \[/code\]SessionLoginBehavior.SSO_WITH_FALLBACK\[code\] : SessionLoginBehavior.SUPPRESS_SSO; authorize(activity, permissions, activityCode, behavior, listener);}private void authorize(Activity activity, String[] permissions, int activityCode, SessionLoginBehavior behavior, final DialogListener listener) { checkUserSession("authorize"); pendingOpeningSession = new Session.Builder(activity). setApplicationId(mAppId). setTokenCache(getTokenCache()). setShouldAutoPublishInstall(getShouldAutoPublishInstall()). build(); pendingAuthorizationActivity = activity; pendingAuthorizationPermissions = (permissions != null) ? permissions : new\[/code\]String[0];\[code\] StatusCallback callback = new StatusCallback() { @Override public void call(Session callbackSession, SessionState state, Exception \[/code\]exception) {\[code\] // Invoke user-callback. onSessionCallback(callbackSession, state, exception, listener); } }; Session.OpenRequest openRequest = new Session.OpenRequest(activity). setCallback(callback). setLoginBehavior(behavior). setRequestCode(activityCode). setPermissions(Arrays.asList(permissions)); openSession(pendingOpeningSession, openRequest, \[/code\]pendingAuthorizationPermissions.length > 0);\[code\]}private void openSession(Session session, Session.OpenRequest openRequest, boolean \[/code\]isPublish) {\[code\] openRequest.suppressLoginActivityVerification(true); if (isPublish) { session.openForPublish(openRequest); } else { session.openForRead(openRequest); }}private void onSessionCallback(Session callbackSession, SessionState state, Exception \[/code\]exception,\[code\] DialogListener listener) { Bundle extras = callbackSession.getAuthorizationBundle(); if (state == SessionState.OPENED) { Session sessionToClose = null; synchronized (Facebook.this.lock) { if (callbackSession != Facebook.this.session) { sessionToClose = Facebook.this.session; Facebook.this.session = callbackSession; Facebook.this.sessionInvalidated = false; } } if (sessionToClose != null) { sessionToClose.close(); } listener.onComplete(extras); } else if (exception != null) { if (exception instanceof FacebookOperationCanceledException) { listener.onCancel(); }\[/code\]else if ((exception instanceof FacebookAuthorizationException) && (extras != null)\[code\] && extras.containsKey(Session.WEB_VIEW_ERROR_CODE_KEY) && extras.containsKey(Session.WEB_VIEW_FAILING_URL_KEY)) { DialogError error = new DialogError(exception.getMessage(), extras.getInt(Session.WEB_VIEW_ERROR_CODE_KEY), extras.getString(Session.WEB_VIEW_FAILING_URL_KEY)); listener.onError(error); } else { FacebookError error = new FacebookError(exception.getMessage()); listener.onFacebookError(error); } }}private boolean validateServiceIntent(Context context, Intent intent) { ResolveInfo resolveInfo = context.getPackageManager().resolveService(intent, 0); if (resolveInfo == null) { return false; } return validateAppSignatureForPackage(context, \[/code\]resolveInfo.serviceInfo.packageName);\[code\]}@Deprecatedpublic void authorizeCallback(int requestCode, int resultCode, Intent data) { checkUserSession("authorizeCallback"); Session pending = this.pendingOpeningSession; if (pending != null) { if (pending.onActivityResult(this.pendingAuthorizationActivity, requestCode, \[/code\]resultCode, data)) {\[code\] this.pendingOpeningSession = null; this.pendingAuthorizationActivity = null; this.pendingAuthorizationPermissions = null; } }}@Deprecatedpublic boolean extendAccessToken(Context context, ServiceListener serviceListener) { checkUserSession("extendAccessToken"); Intent intent = new Intent(); intent.setClassName("com.facebook.katana", \[/code\]"com.facebook.katana.platform.TokenRefreshService");\[code\] if (!validateServiceIntent(context, intent)) { return false; } return context.bindService(intent, new TokenRefreshServiceConnection(context, \[/code\]serviceListener),\[code\] Context.BIND_AUTO_CREATE);}@Deprecatedpublic boolean extendAccessTokenIfNeeded(Context context, ServiceListener \[/code\]serviceListener) {\[code\] checkUserSession("extendAccessTokenIfNeeded"); if (shouldExtendAccessToken()) { return extendAccessToken(context, serviceListener); } return true;}@Deprecatedpublic boolean shouldExtendAccessToken() { checkUserSession("shouldExtendAccessToken"); return isSessionValid() && (System.currentTimeMillis() - lastAccessUpdateMillisecondsAfterEpoch >=\[/code\]REFRESH_TOKEN_BARRIER);\[code\]}private class TokenRefreshServiceConnection implements ServiceConnection { final Messenger messageReceiver = new Messenger( new TokenRefreshConnectionHandler(Facebook.this, this)); final ServiceListener serviceListener; final Context applicationsContext; Messenger messageSender = null; public TokenRefreshServiceConnection(Context applicationsContext, ServiceListener\[/code\]serviceListener) {\[code\] this.applicationsContext = applicationsContext; this.serviceListener = serviceListener; } @Override public void onServiceConnected(ComponentName className, IBinder service) { messageSender = new Messenger(service); refreshToken(); } @Override public void onServiceDisconnected(ComponentName arg) { serviceListener.onError(new Error("Service disconnected")); applicationsContext.unbindService(TokenRefreshServiceConnection.this); } private void refreshToken() { Bundle requestData = http://stackoverflow.com/questions/13738959/new Bundle(); requestData.putString(TOKEN, accessToken); Message request = Message.obtain(); request.setData(requestData); request.replyTo = messageReceiver; try { messageSender.send(request); } catch (RemoteException e) { serviceListener.onError(new Error("Service connection error")); } }}private static class TokenRefreshConnectionHandler extends Handler { WeakReference<Facebook> facebookWeakReference; WeakReference<TokenRefreshServiceConnection> connectionWeakReference; TokenRefreshConnectionHandler(Facebook facebook, TokenRefreshServiceConnection\[/code\]connection) {\[code\] super(); facebookWeakReference = new WeakReference<Facebook>(facebook); connectionWeakReference = new WeakReference<TokenRefreshServiceConnection>\[/code\](connection);\[code\] } @Override public void handleMessage(Message msg) { Facebook facebook = facebookWeakReference.get(); TokenRefreshServiceConnection connection = connectionWeakReference.get(); if (facebook == null || connection == null) { return; } String token = msg.getData().getString(TOKEN); long expiresAtMsecFromEpoch = msg.getData().getLong(EXPIRES) * 1000L; if (token != null) { facebook.setAccessToken(token); facebook.setAccessExpires(expiresAtMsecFromEpoch); Session refreshSession = facebook.session; if (refreshSession != null) { refreshSession.internalRefreshToken(msg.getData()); } if (connection.serviceListener != null) { Bundle resultBundle = (Bundle) msg.getData().clone(); resultBundle.putLong(EXPIRES, expiresAtMsecFromEpoch); connection.serviceListener.onComplete(resultBundle); } } else if (connection.serviceListener != null) { // extract errors only if // client wants them String error = msg.getData().getString("error"); if (msg.getData().containsKey("error_code")) { int errorCode = msg.getData().getInt("error_code"); connection.serviceListener.onFacebookError(new FacebookError(error, \[/code\]null, errorCode));\[code\] } else { connection.serviceListener.onError(new Error(error != null ? error : \[/code\]"Unknown service error"));\[code\] } } if (connection != null) { // The refreshToken function should be called rarely, // so there is no point in keeping the binding open. connection.applicationsContext.unbindService(connection); } }}@Deprecatedpublic String logout(Context context) throws MalformedURLException, IOException { return logoutImpl(context);}String logoutImpl(Context context) throws MalformedURLException, IOException { checkUserSession("logout"); Bundle b = new Bundle(); b.putString("method", "auth.expireSession"); String response = request(b); long currentTimeMillis = System.currentTimeMillis(); Session sessionToClose = null; synchronized (this.lock) { sessionToClose = session; session = null; accessToken = null; accessExpiresMillisecondsAfterEpoch = 0; lastAccessUpdateMillisecondsAfterEpoch = currentTimeMillis; sessionInvalidated = false; } if (sessionToClose != null) { sessionToClose.closeAndClearTokenInformation(); } return response;}@Deprecatedpublic String request(Bundle parameters) throws MalformedURLException, IOException { if (!parameters.containsKey("method")) { throw new IllegalArgumentException("API method must be specified. " + "(parameters must contain key \"method\" and value). See" + " http://developers.facebook.com/docs/reference/rest/"); } return requestImpl(null, parameters, "GET");}@Deprecatedpublic String request(String graphPath) throws MalformedURLException, IOException { return requestImpl(graphPath, new Bundle(), "GET");}@Deprecatedpublic String request(String graphPath, Bundle parameters) throws \[/code\]MalformedURLException, IOException {\[code\] return requestImpl(graphPath, parameters, "GET");}@Deprecatedpublic void dialog(Context context, String action, DialogListener listener) { dialog(context, action, new Bundle(), listener);}@Deprecatedpublic void dialog(Context context, String action, Bundle parameters, final \[/code\]DialogListener listener) {\[code\] parameters.putString("display", "touch"); parameters.putString("redirect_uri", REDIRECT_URI); if (action.equals(LOGIN)) { parameters.putString("type", "user_agent"); parameters.putString("client_id", mAppId); } else { parameters.putString("app_id", mAppId); // We do not want to add an access token when displaying the auth dialog. if (isSessionValid()) { parameters.putString(TOKEN, getAccessToken()); } } if (context.checkCallingOrSelfPermission(Manifest.permission.INTERNET) != \[/code\]PackageManager.PERMISSION_GRANTED) {\[code\] Util.showAlert(context, "Error", "Application requires permission to access \[/code\]the Internet");\[code\] } else { new FbDialog(context, action, parameters, listener).show(); }}@Deprecatedpublic boolean isSessionValid() { return (getAccessToken() != null) && ((getAccessExpires() == 0) || (System.currentTimeMillis() < \[/code\]getAccessExpires()));\[code\]}@Deprecatedpublic void setSession(Session session) { if (session == null) { throw new IllegalArgumentException("session cannot be null"); } synchronized (this.lock) { this.userSetSession = session; }}private void checkUserSession(String methodName) { if (userSetSession != null) { throw new UnsupportedOperationException( String.format("Cannot call %s after setSession has been called.", \[/code\]methodName));\[code\] }}@Deprecatedpublic final Session getSession() { while (true) { String cachedToken = null; Session oldSession = null; synchronized (this.lock) { if (userSetSession != null) { return userSetSession; } if ((session != null) || !sessionInvalidated) { return session; } cachedToken = accessToken; oldSession = session; } if (cachedToken == null) { return null; } List<String> permissions; if (oldSession != null) { permissions = oldSession.getPermissions(); } else if (pendingAuthorizationPermissions != null) { permissions = Arrays.asList(pendingAuthorizationPermissions); } else { permissions = Collections.<String>emptyList(); } Session newSession = new Session.Builder(pendingAuthorizationActivity). setApplicationId(mAppId). setTokenCache(getTokenCache()). build(); if (newSession.getState() != SessionState.CREATED_TOKEN_LOADED) { return null; } Session.OpenRequest openRequest = new \[/code\]Session.OpenRequest(pendingAuthorizationActivity).setPermissions(permissions);\[code\] openSession(newSession, openRequest, !permissions.isEmpty()); Session invalidatedSession = null; Session returnSession = null; synchronized (this.lock) { if (sessionInvalidated || (session == null)) { invalidatedSession = session; returnSession = session = newSession; sessionInvalidated = false; } } if (invalidatedSession != null) { invalidatedSession.close(); } if (returnSession != null) { return returnSession; } // Else token state changed between the synchronized blocks, so // retry.. }}@Deprecatedpublic String getAccessToken() { Session s = getSession(); if (s != null) { return s.getAccessToken(); } else { return null; }}@Deprecatedpublic long getAccessExpires() { Session s = getSession(); if (s != null) { return s.getExpirationDate().getTime(); } else { return accessExpiresMillisecondsAfterEpoch; }}@Deprecatedpublic long getLastAccessUpdate() { return lastAccessUpdateMillisecondsAfterEpoch;}@Deprecatedpublic void setTokenFromCache(String accessToken, long accessExpires, long \[/code\]lastAccessUpdate) {\[code\] checkUserSession("setTokenFromCache"); synchronized (this.lock) { this.accessToken = accessToken; accessExpiresMillisecondsAfterEpoch = accessExpires; lastAccessUpdateMillisecondsAfterEpoch = lastAccessUpdate; }}@Deprecatedpublic void setAccessToken(String token) { checkUserSession("setAccessToken"); synchronized (this.lock) { accessToken = token; lastAccessUpdateMillisecondsAfterEpoch = System.currentTimeMillis(); sessionInvalidated = true; }}@Deprecatedpublic void setAccessExpires(long timestampInMsec) { checkUserSession("setAccessExpires"); synchronized (this.lock) { accessExpiresMillisecondsAfterEpoch = timestampInMsec; lastAccessUpdateMillisecondsAfterEpoch = System.currentTimeMillis(); sessionInvalidated = true; }}@Deprecatedpublic void setAccessExpiresIn(String expiresInSecsFromNow) { checkUserSession("setAccessExpiresIn"); if (expiresInSecsFromNow != null) { long expires = expiresInSecsFromNow.equals("0") ? 0 : \[/code\]System.currentTimeMillis()\[code\] + Long.parseLong(expiresInSecsFromNow) * 1000L; setAccessExpires(expires); }}@Deprecatedpublic String getAppId() { return mAppId;}@Deprecatedpublic void setAppId(String appId) { checkUserSession("setAppId"); synchronized (this.lock) { mAppId = appId; sessionInvalidated = true; }}private TokenCache getTokenCache() { // Intentionally not volatile/synchronized--it is okay if we race to // create more than one of these. if (tokenCache == null) { tokenCache = new SetterTokenCache(); } return tokenCache;}private static String[] stringArray(List<String> list) { String[] array = new String[list.size()]; if (list != null) { for (int i = 0; i < array.length; i++) { array = list.get(i); } } return array;}private static List<String> stringList(String[] array) { if (array != null) { return Arrays.asList(array); } else { return Collections.emptyList(); }}private class SetterTokenCache extends TokenCache { @Override public Bundle load() { Bundle bundle = new Bundle(); if (accessToken != null) { TokenCache.putToken(bundle, accessToken); TokenCache.putExpirationMilliseconds(bundle, \[/code\]accessExpiresMillisecondsAfterEpoch);\[code\] TokenCache.putPermissions(bundle, \[/code\]stringList(pendingAuthorizationPermissions));\[code\] TokenCache.putSource(bundle, AccessTokenSource.WEB_VIEW); TokenCache.putLastRefreshMilliseconds(bundle, \[/code\]lastAccessUpdateMillisecondsAfterEpoch);\[code\] } return bundle; } @Override public void save(Bundle bundle) { accessToken = TokenCache.getToken(bundle); accessExpiresMillisecondsAfterEpoch = \[/code\]TokenCache.getExpirationMilliseconds(bundle);\[code\] pendingAuthorizationPermissions = \[/code\]stringArray(TokenCache.getPermissions(bundle));\[code\] lastAccessUpdateMillisecondsAfterEpoch = \[/code\]TokenCache.getLastRefreshMilliseconds(bundle);\[code\] } @Override public void clear() { accessToken = null; }}@Deprecatedpublic static String getAttributionId(ContentResolver contentResolver) { return Settings.getAttributionId(contentResolver);}@Deprecatedpublic boolean getShouldAutoPublishInstall() { return shouldAutoPublishInstall;}@Deprecatedpublic void setShouldAutoPublishInstall(boolean value) { shouldAutoPublishInstall = value;}@Deprecatedpublic boolean publishInstall(final Context context) { Settings.publishInstallAsync(context, mAppId); return false;}public static interface DialogListener { public void onComplete(Bundle values); public void onFacebookError(FacebookError e); public void onError(DialogError e); public void onCancel();}public static interface ServiceListener { public void onComplete(Bundle values); public void onFacebookError(FacebookError e); public void onError(Error e);}@Deprecatedpublic static final String FB_APP_SIGNATURE = "30820268308201d102044a9c4610300d06092a864886f70d0101040500307a310" + "b3009060355040613025553310b30090603550408130243413112301006035504" + "07130950616c6f20416c746f31183016060355040a130f46616365626f6f6b204" + "d6f62696c653111300f060355040b130846616365626f6f6b311d301b06035504" + "03131446616365626f6f6b20436f72706f726174696f6e3020170d30393038333" + "13231353231365a180f32303530303932353231353231365a307a310b30090603" + "55040613025553310b30090603550408130243413112301006035504071309506" + "16c6f20416c746f31183016060355040a130f46616365626f6f6b204d6f62696c" + "653111300f060355040b130846616365626f6f6b311d301b06035504031314466" + "16365626f6f6b20436f72706f726174696f6e30819f300d06092a864886f70d01" + "0101050003818d0030818902818100c207d51df8eb8c97d93ba0c8c1002c928fa" + "b00dc1b42fca5e66e99cc3023ed2d214d822bc59e8e35ddcf5f44c7ae8ade50d7" + "e0c434f500e6c131f4a2834f987fc46406115de2018ebbb0d5a3c261bd97581cc" + "fef76afc7135a6d59e8855ecd7eacc8f8737e794c60a761c536b72b11fac8e603" + "f5da1a2d54aa103b8a13c0dbc10203010001300d06092a864886f70d010104050" + "0038181005ee9be8bcbb250648d3b741290a82a1c9dc2e76a0af2f2228f1d9f9c" + "4007529c446a70175c5a900d5141812866db46be6559e2141616483998211f4a6" + "73149fb2232a10d247663b26a9031e15f84bc1c74d141ff98a02d76f85b2c8ab2" + "571b6469b232d8e768a7f7ca04f7abe4a775615916c07940656b58717457b42bd" + "928a2";\[/code\]}