开发者

BlackBerry forcefully interupt the facebook connect

开发者 https://www.devze.com 2023-03-26 16:46 出处:网络
I am using the following method to share my app data but if the user clicks back on the main screen, I would like it to forcefully close facebook connect.

I am using the following method to share my app data but if the user clicks back on the main screen, I would like it to forcefully close facebook connect.

public class FacebookIntegration {

    private static User user;
    private static String NEXT_URL = "http://www.facebook.com/connect/login_success.html";
    private static String APPLICATION_ID ;
    private static String APPLICATION_SECRET ;
    private static String[] PERMISSIONS = Facebook.Permissions.USER_DATA_PERMISSIONS;
    public static boolean posted = false;
    private static String[] postPermissions = Facebook.Permissions.PUBLISHING_PERMISSIONS;
    private static SharePopup _obj;
    private static boolean exception = false;

    public static boolean integrate(SharePopup obj) {

        _obj = obj;
        ApplicationSettings as = new ApplicationSettings(NEXT_URL, APPLICATION_ID, APPLICATION_SECRET, PERMISSIONS);
        ApplicationSettings as2 = new ApplicationSettings(null, APPLICATION_ID, APPLICATION_SECRET, PERMISSIONS);

        Facebook fb = Facebook.getInstance(as);

         _obj.close();
        try {
            user = fb.getCurrentUser();
        } catch (FacebookException e1) {

            e1.printStackTrace();
            exception = true;
        }
        if (!exception) {
            try {

                fb.getCurrentUser(new BasicAsyncCallback() {
                    public void onComplete(com.blackberry.facebook.inf.Object[] objects, final java.lang.Object state) {
                        FacebookIntegration.this.user = (User) objects[0];
                        Vector prayerTimes = (Vector) PrayerTimesDTO.getPrayerTimes();
                        StringBuffer post = new StringBuffer("avbc");

                        user.publishStatus(post.toString());

                        posted = true;

                        user.publishPost("stream.publish", "published through the Facebook API", APPLICATION_SECRET, null, null, null, user.getId());

                    }

                    public void onException(final Exception e, final java.lang.Object state) {
                        e.printStackTrace();

                    }
                });

            } catch (FacebookException e) {
                e.printStackTrace();
            } finally {
                fb.logout(true);


        开发者_如何学运维    }
        }
        return true;

    }


}


I have been pondering this since you first posted it. I don't think anyone can help you because we would have to know what the Facebook object does. That is probly where you will have to close the connection.


A. In your MainScreen class override the onClose function:

public boolean onClose() {
     FacebookIntegration.closeConnection(); 
     return super.onClose();
}



B. Change FacebookIntegration as follows:

  1. Put Facebook object as static field in the class

    private static Facebook fb;

  2. Change the line of: Facebook fb = Facebook.getInstance(as);
    to be fb = Facebook.getInstance(as);

  3. Add the closeConnection method to FacebookIntegration as follows:

    public static void closeConnection() { fb.logout(true); }

0

精彩评论

暂无评论...
验证码 换一张
取 消