Send JSON Request from blackberry application

拜拜、爱过 提交于 2019-12-01 14:34:16

When running the application in simulator, make sure you enabled the Launch Mobile Data System Connection Service (MDS-CS) with simulator in Eclipse's "Run Configurations" or "Debug Configurations"->"Simulator tab"->"General tab".

If it is not enabled, you should check this guide "Testing a BlackBerry device application with the BlackBerry Smartphone Simulator", particularly the "Testing a BlackBerry device application that uses an HTTP connection" section. To make a long story short, you have to enable the MDS-CS. After enabling it, you should restart your simulator. Here is a quote from this guide:

Start the BlackBerry MDS Connection Service when you start the BlackBerry Smartphone Simulator

  1. In Eclipse®, on the Run menu, click Debug Configurations or Run Configurations.
  2. Expand the BlackBerry Simulator item.
  3. Complete one of the following tasks:
    • To work with an existing launch configuration, under BlackBerry Simulator, click a launch configuration.
    • To create a new launch configuration, right-click BlackBerry Simulator, select New.
  4. Click the Simulator tab.
  5. Click the General tab.
  6. Select the Launch Mobile Data System Connection Service (MDS-CS) with simulator check box.
  7. Click Apply.

Edit:
Alternatively, when using a simulator you can add ;deviceside=true suffix to the url that you pass to Connector.open(). By setting deviceside=true you specify that the underlying TCP connection should be opened directly from the handheld (simulator in your case), therefore BlackBerry MDS Connection Service will not be used. Here is a code snippet based on your code:

if (DeviceInfo.isSimulator()) {
    urlPath += ";deviceside=true";
} else {
    urlPath += connectionDependentSuffix; // suffix that is relevant to
                                          // the desired connection option
}
c = (HttpConnection)Connector.open(urlPath);

Hope this helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!