Java 类com.facebook.android.AsyncFacebookRunner 实例源码

项目:facebook-android-sdk    文件:Tests.java   
public void onComplete(Bundle values) {
    final String postId = values.getString("post_id");
    if (postId != null) {
        Log.d("Facebook-Example", "Dialog Success! post_id=" + postId);
        new AsyncFacebookRunner(authenticatedFacebook).request(postId, 
                new TestPostRequestListener());
    } else {
        Tests.this.runOnUiThread(new Runnable() {
            public void run() {
                wallPostText.setText("Wall Post Failure");
                wallPostText.setTextColor(Color.RED);
            }
        });
    }
}
项目:Socialite    文件:FacebookConnector.java   
@Override
public void logout() {
    SessionEvents.onLogoutBegin(SessionListenerType.FACEBOOK_SESSION_LISTENER);
    AsyncFacebookRunner asyncRunner = new AsyncFacebookRunner(this.facebook);
    asyncRunner.logout(activity.getApplicationContext(), new LogoutRequestListener());
}
项目:kaorisan    文件:LoginActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    loginActivity = this;
    SQLiteDatabaseAdapter.setContext(this);

    checkGooglePlayServices();

    mPlusClient = new PlusClient.Builder(this, this, this)
    .setVisibleActivities("http://schemas.google.com/AddActivity",
                    "http://schemas.google.com/BuyActivity").setScopes(Scopes.PLUS_LOGIN, Scopes.PLUS_PROFILE).build();

    btnLoginGoogle = (Button) findViewById(R.id.btn_login_google);
    initGoogleButton();

    genKeyHash();
    resource = getResources();

    DebugLog.logd("On create");

    // Create the Facebook Object using the app id.
    if (Utility.mFacebook == null) {
        Utility.mFacebook = new Facebook(APP_ID);
    }
    // Instantiate the asynrunner object for asynchronous api calls.
    if (Utility.mAsyncRunner == null) {
        Utility.mAsyncRunner = new AsyncFacebookRunner(Utility.mFacebook);
    }

    SessionStore.restore(Utility.mFacebook, this);

    SessionEvents.addAuthListener(authenListener);
    SessionEvents.addLogoutListener(logoutListener);

    Settings.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);

    btnLoginFaceBook = (Button) findViewById(R.id.btn_login_facebook);
    initFacebookButton();

    SessionEvents.addAuthListener(mSessionListener);
    SessionEvents.addLogoutListener(mSessionListener);

    if (Utility.mFacebook.isSessionValid() && isLogout == 0 && currentSocial == Social.FACEBOOK) {
        DebugLog.logd("On facebook Create");
        if (Utils.checkInternetConnect(this)) {
            requestGetUserData();
        }
    }

    if (currentSocial == Social.GOOGLE && isLogout == 0) {
        DebugLog.logd("On Google Create");
        mPlusClient.connect();
    }
    checkLogout();

}
项目:kaorisan    文件:LoginActivity.java   
private void checkLogout() {

        if (isLogout == 1 && NetworkUtil.NETWORK_STATE != NetworkUtil.TYPE_NOT_CONNECTED) {
            if (currentSocial == Social.FACEBOOK) {
                if (Utility.mFacebook.isSessionValid()) {
                    SessionEvents.onLogoutBegin();
                    AsyncFacebookRunner asyncRunner = new AsyncFacebookRunner(Utility.mFacebook);

                    try {
                        if (showProcess != null) {
                            if (showProcess.isShowing()) {
                                showProcess.dismiss();
                            }
                            showProcess = null;
                        }

                        showProcess = new ProgressDialog(this);
                        showProcess.setCancelable(false);
                        showProcess.setTitle(getResources().getString(R.string.txt_logout));

                        showProcess.show();
                    } catch (Exception ex) {
                        DebugLog.logd("checkLogout ??? Do not know what happen with show process, " +
                                "maybe the facebook already hace show process");
                    }
                    asyncRunner.logout(this, new LogoutRequestListener());
                }

                if(TaskActivity.taskActivity != null){
                    TaskActivity.taskActivity.finish();
                }
            } else if (currentSocial == Social.GOOGLE) {
                DebugLog.logd("On google logout");
                mPlusClient.disconnect();

            }

            if(CacheData.getInstant().getTokenKaorisan() != null){
                if(!CacheData.getInstant().getTokenKaorisan().isEmpty()){
                    DebugLog.logd("Delete token kaorisan in SQLite");
//                  UserDao.deleteUser(CacheData.getInstant().getTokenKaorisan());
                    UserDao.setCurrentUser("", "0", "", "");
                }
            }
        }

        if(CacheData.getInstant().getCurrentUser() != null){
            if(CacheData.getInstant().getCurrentUser().getPushToken() != null && isLogout == 1){
                if (GCMRegistrar.isRegisteredOnServer(TaskActivity.taskActivity)) {
                    ServerUtilities.unregister(TaskActivity.taskActivity, CacheData.getInstant().getCurrentUser().getPushToken());
                    Log.i(TAG, "Unregister server");
                } else {
                    // This callback results from the call to unregister made on
                    // ServerUtilities when the registration to the server failed.
                    Log.i(TAG, "Ignoring unregister callback");
                }
            }
        }

        Utils.resetCacheData();
        isLogout = 0;
    }
项目:IPRJapp    文件:Tutorial_1.java   
@SuppressWarnings("deprecation")
@Override
   public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);        

        if (savedInstanceState != null)

            TutoRes = savedInstanceState.getInt("TutoRes");
        facebook = new Facebook(APP_ID);
        AsyncFacebookRunner   mAsyncRunner = new AsyncFacebookRunner(facebook);
        //loginFacebook();

requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.tutorial_1);
//setLogin();



Session.openActiveSession(this, true, new Session.StatusCallback() {


    @Override
    public void call(final Session session, SessionState state, Exception exception) {
        if (session.isOpened()) {

            Request.newMeRequest(session, new Request.GraphUserCallback() {

                  @Override
                  public void onCompleted(GraphUser user, Response response) {

                      if (user != null) {

                        //welcome = (TextView) findViewById(R.id.welcome);                      
                        Userid = user.getId();
                        User_name= user.getFirstName();


                        }
                  }
                }).executeAsync();
            }
    }
  }); 



final Button  Button = (Button) findViewById(R.id.button1);

Button.setOnClickListener(new View.OnClickListener() {

       @Override
      public void onClick(View v) {

        if(Userid != null && User_name != null){

             Intent intent = new Intent();
             intent.setClass(Tutorial_1.this,Tutorial_2.class);
             db.addUsuario(new Usuario(User_name,Userid));
            startActivity(intent);
             finish();


        }

        else {

            Toast.makeText(getApplicationContext(), "Aguarde o carregamento dos dados do perfil do Facebook", Toast.LENGTH_SHORT).show();

        }

       }

});
   }