blackberry / Samples-for-Java

Samples for BBOS Java Apps
106 stars 195 forks source link

Facebook Network issues #28

Open vaibhavb24 opened 11 years ago

vaibhavb24 commented 11 years ago

Hello everyone,

i am using FacebookBlackBerrySDK-v0.8.25.jar for post status but this is working on wifi connection but not working on sim network please give me any solutions for this problem immediately............

timwindsor commented 11 years ago

Are you running the MDS Simulator? Have you tried setting up a Wifi Network on the SIM?

vaibhavb24 commented 11 years ago

Hello it's working on simulator and device with wifi Network but i 'm using sim network then not working

vaibhavb24 commented 11 years ago

Hello timwindsor, please check my code and give me solutions

import net.rim.device.api.ui.Field; import net.rim.device.api.ui.FieldChangeListener; import net.rim.device.api.ui.component.ButtonField; import net.rim.device.api.ui.component.Dialog; import net.rim.device.api.ui.container.MainScreen; import com.blackberry.facebook.ApplicationSettings; import com.blackberry.facebook.Facebook; import com.blackberry.facebook.inf.Profile; import com.blackberry.facebook.inf.User;

public class MyScreen extends MainScreen {

private User user;
String NEXT_URL = "http://www.facebook.com/connect/login_success.html";

String APPLICATION_ID = "xxxxxxxxxxxx";
String APPLICATION_SECRET = "xxxxxxxxxxxxxxxxxx";
String[] PERMISSIONS = Facebook.Permissions.ALL_PERMISSIONS;
private Facebook fb;
private ApplicationSettings as;
Profile profile;
ButtonField send;

public MyScreen()
{
    send=new ButtonField("send",ButtonField.CONSUME_CLICK);
    send.setChangeListener(new FieldChangeListener() {

        public void fieldChanged(Field field, int context) {
            // TODO Auto-generated method stub

            FBPost();

        }
    });

    add(send);

}

// FBpost calling
private void FBPost() {

    ApplicationSettings as = new ApplicationSettings(NEXT_URL,
            APPLICATION_ID, APPLICATION_SECRET, PERMISSIONS);

    Facebook fb = Facebook.getInstance(as);

    try {

        user = fb.getCurrentUser();

        String result = user.publishStatus("hi test fb2");

        if ((result != null) && !result.trim().equals("")) {
            Dialog.inform("Publish Success.");

        } else {
            Dialog.inform("Publish Failed.");

        }
    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
    }

}

}

boogie4eva commented 11 years ago

I think i have done this before , what you need to do is download the source of the sdk and modify the connection access code to use your own connection class .

timwindsor commented 11 years ago

For use with a sim network, you'll need to use the MDS Simulator. Or modify the connection code cause it's likely trying to use MDS for the network transport, which will fail on the simulator without MDS Sim running.