Я использую следующий метод для обмена данными своего приложения, но если пользователь нажимает кнопку назад на главном экране, я бы хотел принудительно закрыть Facebook facebook.
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;
}
}