当前位置: 首页>>代码示例>>Java>>正文


Java Request.executeAsync方法代码示例

本文整理汇总了Java中com.facebook.Request.executeAsync方法的典型用法代码示例。如果您正苦于以下问题:Java Request.executeAsync方法的具体用法?Java Request.executeAsync怎么用?Java Request.executeAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.facebook.Request的用法示例。


在下文中一共展示了Request.executeAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUserFriendList

import com.facebook.Request; //导入方法依赖的package包/类
public static  Promise<List<GraphUser>, BError, Void>  getUserFriendList(){

        final Deferred<List<GraphUser>, BError, Void> deferred = new DeferredObject<>();

        
        if (!Session.getActiveSession().getState().isOpened())
        {
            return deferred.reject(new BError(BError.Code.SESSION_CLOSED));
        }
        Request req = Request.newMyFriendsRequest(Session.getActiveSession(), new Request.GraphUserListCallback() {
            @Override
            public void onCompleted(List<GraphUser> users, Response response) {
                deferred.resolve(users);
            }
        });

        req.executeAsync();
        
        return deferred.promise();
    }
 
开发者ID:MobileDev418,项目名称:chat-sdk-android-push-firebase,代码行数:21,代码来源:BFacebookManager.java

示例2: postStatus

import com.facebook.Request; //导入方法依赖的package包/类
public void postStatus(View view){
    EditText editText = (EditText) findViewById(R.id.editText);
    final String statusText = editText.getText().toString();
    Session session = Session.getActiveSession();
    if (session != null) {

        if (session.isOpened() && hasPublishPermission()) {
            Request request = Request
                    .newStatusUpdateRequest(Session.getActiveSession(), statusText, null, null, new Request.Callback() {
                        @Override
                        public void onCompleted(Response response) {
                            showPublishResult(statusText, response.getGraphObject(), response.getError());
                        }
                    });
            request.executeAsync();
            return;
        }
        else {
            Toast.makeText(this, getString(R.string.err_notConnected), Toast.LENGTH_SHORT).show();
        }
    }
    else {
        Toast.makeText(this, getString(R.string.err_notConnected), Toast.LENGTH_SHORT).show();
    }
}
 
开发者ID:jacquesgiraudel,项目名称:TP-Formation-Android,代码行数:26,代码来源:TestFacebookActivity.java

示例3: retrieveEmailAddress

import com.facebook.Request; //导入方法依赖的package包/类
public void retrieveEmailAddress() {
    Request request = Request.newMeRequest(ParseFacebookUtils.getSession(),
            new Request.GraphUserCallback() {
                @Override
                public void onCompleted(GraphUser user, Response response) {
                    if (user != null) {
                        try {
                            String email = user.getInnerJSONObject().get("email").toString();

                            ParseUser.getCurrentUser().setEmail(email);
                            ParseUser.getCurrentUser().saveEventually();
                        } catch (JSONException e) {
                            Log.e("CatChatInbox", "Failed to parse JSON from FB", e);
                        }

                    }
                }
            }
    );
    request.executeAsync();
}
 
开发者ID:cat-chat,项目名称:cat-chat-android,代码行数:22,代码来源:CatChatApplication.java

示例4: getNearPlaces

import com.facebook.Request; //导入方法依赖的package包/类
@Override
public void getNearPlaces(Location location, int radius, final ExternalDataListener dataListener) {
	
	final Session session = Session.getActiveSession();
	if (session != null & session.isOpened()) {
		
		// Make an API call to get nearby places and define a new callback to handle the response
		Request request = Request.newPlacesSearchRequest(session, location, (int)radius, 100, "", 
				new GraphPlaceListCallback() {

			@Override
			public void onCompleted(List<GraphPlace> graphPlaces, Response response) {
				List<Place> places =  new ArrayList<Place>();
				for (GraphPlace place : graphPlaces) {
					//Log.v(TAG, place.getInnerJSONObject().toString());
					places.add(createPlace(place));
				}
				dataListener.fireCollectionAdded(places);
			}
		});
		request.executeAsync();
	}
}
 
开发者ID:vegaen,项目名称:UbiNomadLib,代码行数:24,代码来源:FacebookProviders.java

示例5: saveFacebookInfo

import com.facebook.Request; //导入方法依赖的package包/类
private void saveFacebookInfo() {		
	Request request = Request.newMeRequest(ParseFacebookUtils.getSession(), new Request.GraphUserCallback() {
		@Override
		public void onCompleted(GraphUser graphUser, Response response) {
			if (graphUser != null) {
				new DownloadProfilePictureTask().execute(new String[] { graphUser.getId(), graphUser.getName() });
			} else if (response.getError() != null) {
				if ((response.getError().getCategory() == FacebookRequestError.Category.AUTHENTICATION_RETRY)
						|| (response.getError().getCategory() == FacebookRequestError.Category.AUTHENTICATION_REOPEN_SESSION)) {
					Log.d(LOG_TAG, "The facebook session was invalidated.");
				} else {
					Log.e(LOG_TAG, "Some other error: " + response.getError().getErrorMessage());
				}
			}
		}

	});
	request.executeAsync();
}
 
开发者ID:benbek,项目名称:HereAStory-Android,代码行数:20,代码来源:LoginActivity.java

示例6: doPost

import com.facebook.Request; //导入方法依赖的package包/类
protected void doPost() {
	if(!posting)
	{
		posting=true;
		Request request = Request
				.newStatusUpdateRequest(Session.getActiveSession(), dataToPost, new Request.Callback() {
					@Override
					public void onCompleted(Response response) {
						//response.getError().getCategory().
						if(response.getError()==null)
						{
						Log.wtf("Socialify", "Posted to wall! "+response.toString());
						finish();
						}
						else
						{
							showError();
							posting=false;
						}
					}
				});
		request.executeAsync();
	}
}
 
开发者ID:ravibhoraskar,项目名称:bladedroid,代码行数:25,代码来源:PostActivity.java

示例7: requestAccounts

import com.facebook.Request; //导入方法依赖的package包/类
/**
 * Asynchronously requests the Page accounts associated with the linked account. Requires an opened active {@link Session}.
 *
 * @param callback a {@link Callback} when the request completes.
 * @return true if the request is made; false if no opened {@link Session} is active.
 */
boolean requestAccounts(Callback callback) {
    boolean isSuccessful = false;

    Session session = Session.getActiveSession();
    if (session != null && session.isOpened()) {
        // Construct fields to request.
        Bundle params = new Bundle();
        params.putString(ACCOUNTS_LISTING_FEILDS_KEY, ACCOUNTS_LISTING_FIELDS_VALUE);

        // Construct and execute albums listing request.
        Request request = new Request(session, ACCOUNTS_LISTING_GRAPH_PATH, params, HttpMethod.GET, callback);
        request.executeAsync();

        isSuccessful = true;
    }
    return isSuccessful;
}
 
开发者ID:groundupworks,项目名称:wings,代码行数:24,代码来源:FacebookEndpoint.java

示例8: requestAlbums

import com.facebook.Request; //导入方法依赖的package包/类
/**
 * Asynchronously requests the albums associated with the linked account. Requires an opened active {@link Session}.
 *
 * @param id       may be {@link #ME} or a Page id.
 * @param callback a {@link Callback} when the request completes.
 * @return true if the request is made; false if no opened {@link Session} is active.
 */
boolean requestAlbums(String id, Callback callback) {
    boolean isSuccessful = false;

    Session session = Session.getActiveSession();
    if (session != null && session.isOpened()) {
        // Construct fields to request.
        Bundle params = new Bundle();
        params.putString(ALBUMS_LISTING_LIMIT_KEY, ALBUMS_LISTING_LIMIT_VALUE);
        params.putString(ALBUMS_LISTING_FEILDS_KEY, ALBUMS_LISTING_FIELDS_VALUE);

        // Construct and execute albums listing request.
        Request request = new Request(session, id + TO_ALBUMS_LISTING_GRAPH_PATH, params, HttpMethod.GET, callback);
        request.executeAsync();

        isSuccessful = true;
    }
    return isSuccessful;
}
 
开发者ID:groundupworks,项目名称:wings,代码行数:26,代码来源:FacebookEndpoint.java

示例9: call

import com.facebook.Request; //导入方法依赖的package包/类
@Override
public void call(final Session session, SessionState state, Exception exception) {
    if (state.isOpened()) {
        Log.d("Facebook token", session.getAccessToken());
        Request meRequest = Request.newMeRequest(session, new Request.GraphUserCallback() {
            @Override
            public void onCompleted(GraphUser user, Response response) {
                Login login = new Login(user.getProperty("email").toString(), session.getAccessToken(), "facebook");
                new CheckUserCredentials(MainActivity.this).execute(login);
                session.closeAndClearTokenInformation();
            }
        });
        meRequest.executeAsync();
    }
}
 
开发者ID:Aptoide,项目名称:aptoide-backup-apps,代码行数:16,代码来源:MainActivity.java

示例10: requestAsync

import com.facebook.Request; //导入方法依赖的package包/类
/**
 * Request to login async.
 * 
 * @param strPath
 *            - Path of login.
 * @param callback
 *            - Call back function.
 */
public <T> void requestAsync(	String strPath,
								final OnResult<T> callback)
{
	Settings.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);
	Settings.addLoggingBehavior(LoggingBehavior.REQUESTS);
	Session session = Session.getActiveSession();
	Request request =
			Request.newGraphPathRequest(session, strPath,
					new Request.Callback()
					{
						@Override
						public void onCompleted(Response response)
						{
							if (response.getError() != null)
							{
								Log.i("MainActivity",
										String.format(
												"Error making request: %s",
												response.getError()));
							}
							else
							{
								GraphUser user =
										response.getGraphObjectAs(GraphUser.class);
								callback.onResult((T) user);
								Log.i("MainActivity",
										String.format(
												"Name: %s",
												user.getName()));
							}
						}
					});
	request.executeAsync();
}
 
开发者ID:netanelkl,项目名称:guitar_guy,代码行数:43,代码来源:FacebookProfileConnector.java

示例11: getUser

import com.facebook.Request; //导入方法依赖的package包/类
@Override
public void getUser(final Callback<SocialMember> callback) {
    if (notifyIfNotLoggedIn(callback)) {
        return;
    }

    //If the profile for the current user has already been fetched use the cached result.
    if (userProfile != null) {
        callback.onSuccess(userProfile);
        return;
    }

    Session session = Session.getActiveSession();
    Request request = Request.newMeRequest(session, new Request.GraphUserCallback() {
        @Override
        public void onCompleted(GraphUser user, Response response) {
            if (!notifyIfError(response, callback)) {
                logger.debug(user.getUsername() + ":" + user.getName() + ":" + user.getFirstName()
                        + ":" + user.getLastName() + ":" + user.getId());
                logger.debug(user.getProperty("email") + "");
                SocialMember member = new SocialMember(Long.parseLong(user.getId()), user.getName());
                member.setEmail(user.getProperty("email") + "");
                callback.onSuccess(member);
            }
        }
    });
    Bundle params = request.getParameters();
    params.putString("fields", "email,id,name");
    request.setParameters(params);
    request.executeAsync();
}
 
开发者ID:edx,项目名称:edx-app-android,代码行数:32,代码来源:FacebookProvider.java

示例12: goToHome

import com.facebook.Request; //导入方法依赖的package包/类
public void goToHome(final Session session){
    // Obtenemos nuestros datos para crear el usuario que nos represente
    Request request = Request.newMeRequest(session,
            new Request.GraphUserCallback() {
                @Override
                public void onCompleted(GraphUser user, Response response) {
                    // If the response is successfulHome
                    if (session == Session.getActiveSession()) {
                        // Empezar aqui a trabajar con la UI
                        if (user != null) {
                            Utilities.storeRegistrationId(context, user.getId(), user.getName());
                            Intent intent = new Intent(activity, Home.class);
                            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                            startActivity(intent);
                            finish();
                        } else {
                            Crouton.makeText(activity, getString(R.string.error_unknown), Style.ALERT).show();
                        }
                    }
                    if (response.getError() != null) {
                        // Handle errors, will do so later.
                        Crouton.makeText(activity, getString(R.string.error_unknown), Style.ALERT).show();
                    }
                }
            });
    request.executeAsync();
}
 
开发者ID:pacomf,项目名称:Shorcial,代码行数:28,代码来源:Inicio.java

示例13: onSessionStateChanged

import com.facebook.Request; //导入方法依赖的package包/类
public void onSessionStateChanged(final com.facebook.Session session, SessionState state, Exception exception) {
	if (session != null && session.isOpened()) {
		
		Log.i(TAG, "Usu�rio conectado!");
		
		// fazer pedido para o /me API
		Request req = Request.newMeRequest(session, new Request.GraphUserCallback() {
			
			@Override
			public void onCompleted(GraphUser user, Response response) {
				if (user != null) {
					TextView nameText = (TextView) findViewById(R.id.name);
					nameText.setText(user.getFirstName() + " " + user.getLastName());
					
					TextView emailText = (TextView) findViewById(R.id.email);
					emailText.setText(user.getProperty("email").toString());
					
					ProfilePictureView ppv = (ProfilePictureView) findViewById(R.id.fbImg);
					ppv.setVisibility(View.VISIBLE);
					ppv.setProfileId(user.getId());
					
					
					Button listarButton = (Button) findViewById(R.id.listarButton);
					listarButton.setVisibility(View.VISIBLE);
					
					recoverFriends(session);
				}
			}
		});
		req.executeAsync();
	}
	else {
		Log.i(TAG, "Usu�rio desconectado!");
	}
}
 
开发者ID:JGeovaniApk,项目名称:AmiguinhosFacebookkk,代码行数:36,代码来源:MainActivity.java

示例14: recoverFriends

import com.facebook.Request; //导入方法依赖的package包/类
public void recoverFriends(com.facebook.Session session) {
		
		Request req = Request.newMyFriendsRequest(session, new Request.GraphUserListCallback() {
			
			@Override
			public void onCompleted(List<GraphUser> users, Response response) {
				
				
				if (users != null) {
					for (int i = 0; i < users.size(); i++) {
						GraphUser user = users.get(i);
						Amigo amigo = new Amigo
						(
//							Long.parseLong(user.getId()), 
							user.getName()
						);
						
						listaAmigos.add(amigo);
						
						Log.d(TAG, "User " + user.getId() + ": " + user.getName());
					}
				}
//				Log.i(TAG, "resposta: " + response);
			}
			
		});
		req.executeAsync();
	}
 
开发者ID:JGeovaniApk,项目名称:AmiguinhosFacebookkk,代码行数:29,代码来源:MainActivity.java

示例15: requestFacebookFriends

import com.facebook.Request; //导入方法依赖的package包/类
private void requestFacebookFriends(Session session) {
    Request friendsRequest = createRequest(session);
    friendsRequest.setCallback(new Request.Callback() {

        @Override
        public void onCompleted(Response response) {
        	Log.d(TAG, response.toString());
            List<GraphUser> friends = getResults(response);
            parseUserFromFQLResponse(response);
        }
    });
    friendsRequest.executeAsync();
}
 
开发者ID:josenaves,项目名称:facebook-friends,代码行数:14,代码来源:FriendsActivity.java


注:本文中的com.facebook.Request.executeAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。