Prob HttpConnection BlackBerry running in the Simulator

I want to call a url and get the response of the url of my Blackberry App data. For this, I use HttpConnection. Here is the code I use:

Import net.rim.device.api.ui.container.MainScreen;
Import net.rim.device.api.ui.UiApplication;
Import net.rim.device.api.ui.component.LabelField;
Import net.rim.device.api.ui.component.Dialog;

Import javax.microedition.io.Connector;
Import javax.microedition.io.ContentConnection;
Import javax.microedition.io.HttpConnection;
import java.io.DataInputStream;
import java.io.IOException;

SerializableAttribute public class TestApp extends UiApplication {}

private screen _mainScreen;

private static TestApp _app.

public TestApp() {}
_mainScreen = new MainScreen();

TestField LabelField = new LabelField ("hello world");

_mainScreen.Add (testField);

pushScreen (_mainScreen);

C HttpConnection = null;
DataInputStream tell = null;

try {}
System.out.println("0");
c = (HttpConnection) Connector.open ("http://www.google.com");

System.out.println("1");
int rc = c.getResponseCode ();
System.out.println("2");
If (rc! = HttpConnection.HTTP_OK) {}
throw new IOException ("HTTP response code:" + rc);
}
System.out.println("3");
say = c.openDataInputStream ();
System.out.println("4");
int len = (int) c.getLength ();
If (len > 0) {}
data Byte [] = new ubyte [len];
dis.readFully (data);
} else {}
int ch;
While ((ch = dis.read ())! = - 1) {}
//...
}
}
} catch (Exception e) {}
e.printStackTrace ();
} {Finally

try {}
If (say! = null)
tell. Close();
If (c! = null)
c.Close ();
} catch (IOException e) {}
e.printStackTrace ();
}
{} catch (NullPointerException e)
e.printStackTrace ();
}
}

}

Public Shared Sub main (String [] args) {}
_APP = new TestApp();
_APP.enterEventDispatcher ();

}
}

When I try to run the code in the Simulator, I get ' 0 ', then ' 1' and after that, after much time "no trace of the stack" doesn't appear in the debug window, and as soon as the text makes its appearance, level with the text app becomes visible in the Simulator screen. There is no problem in the internet connection in the Simulator, I set up the Wi - Fi and I tested it I open any Web site in the browser. What is the problem in my code?

You must start MDS

MDS is service or bridge to connect to internet for simulater

install MDS and run it solve

Download now

Tags: BlackBerry Developers

Similar Questions

  • How to create the .cod file to run on the Simulator BB9900

    Hi, I already from the zip package in order to use the bbwp command to create the .cod file and be able to run on the simulator of BB9900, but when I run this command as described in: https://developer.blackberry.com/html5/documentation/compile_ww_app_for_smartphones_1873321_11.html

    It creates two files, each with a .bar file, this type of file, I can't run it on the 9900 Simulator but a .cod file is required to run applications on the sim card.

    I don't know how to create the .cod file.

    Thank you

    Have you used Blackberry Webworks SDK for smartphone or Tablet SDK? The .cod files should be located in the subfolder OTAInstall of your output folder if you are using the Webworks SDK for Smartphone

  • Application created using the BB for Eclipse plugin does not run in the Simulator

    Hi all!

    I created an application using BB plugin for Eclipse.  I try to run in the Simulator, but it never gets displayed (the application icon is never shown).  However, I create a "Hello World" sample, which works perfectly in the Simulator.  My application in Eclipse has never shows all files .cod or .jad, there only have files .jdp and .rapc

    My doesn´t app have encoding problems or errors of any kind (at least not displayed in the view of error).

    TIP: I have copy - paste code in different applications, is that a problem?

    I tried:

    • Restart Eclipse,
    • Configuration of active building of blackberry,
    • Cleaning of the project,
    • Creation of the project,
    • Reinstall Eclipse,

    but none of this seems to work.

    Can someone help me please?

    Best regards

    Juan.

    Hi all!

    In the event that a person gets the same problem, I mentioned.  I found the solution: it turns out that I had a very high class with a lot of code on it and that s the reason why the application does not get launched into the Simulator.  What I did that I shared this class on the 4different classes each managing different parts of the code and now it works perfectly.

    Hope someone is enjoying this, cause I spent a lot of time trying to figure out what the problem was.

    Best regards

    Juan.

  • Discover the error of work when you try to run on the Simulator

    I get an error when I try to run my application of Flash Builder for the Simulator:

    An internal error occurred during: "Discover job."

    1

    I ping the Simulator without problem.
    I was at this for hours. Here is my configuration:

    -Flash Builder 4.5.1

    -Flex SDK 4.6.0
    -BlackBerryTabletSDK Air 2.0

    -BlackBerryPlayBookSimulator 2.0

    -VMWare Player 4.0.2

    -on Win 7 Pro 64-bit

    Any ideas?

    I have:

    -Upgrade Flash Builder to 4.6 (which took forever)
    -Re-installed Air BlackBerryTabletSDK 2.0 and integrated with FB 4.6

    Seems to work now.

  • Apps of the problem running in the Simulator - net_rim_xml not found.

    I'm starting to do some Java development. I'm under the Simulator in Windows using the JDE environment to see how the code works.  (I normally run Ubuntu as my main OS.)

    I can run all the examples of code very well when my Simulator is a 9500-JDE, but when I switch to a 8300-ATT-JDE - 4.2 I get a message, "the Source code is not available" in the java window not found 'Module 'net_rim_xml_org'. Error starting : Module 'net_rim_xml_org' not found. »

    What happens on a XP (running under VirtualBox) instance and an instance of Windows 7.

    I installed and re-installed the JDE just to see.

    I also googled and not found the answer.

    TIA

    The code is forward but not backward compatible.

    You develop using JDE 4.7 I guess, so you can execute code in 4.7 or higher.

    Develop for a race of 8300 4.2.1 (Simulator or device), you'll need JDE 4.2.1.

  • Rental app run on the Simulator, but not in real device!

    Hello

    I made a simple application using GPSDemo in JDE, I get altitude, longitude, latitude... I tried in the Simulator (9000) and it worked perfectly.

    But when I put it on my BB (bold 9000), I can't get the location information. I've done some tests and I think it's because the location.isValid () return false!

    I checked the settings of the BB and the GPS is activated.

    Do you know what is the problem? And what can be the solution ?

    Thanks for your help and I apologize if my sentences are strange, I'm French and not very versed in English ^^...

    Ok! I found the solution! The problem wasn't my code, it came from the camera. I had update (outdoor) GPS data in the advanced options because it was the first time I tried to use it.

    And now it works perfectly!

    Thank you for all your help

  • Blackberry app in the world running on the Blackberry 10 Simulator

    Hello

    I would like to run blackberry apps world that I download on App world on the Simulator.

    I could do with the pre OS 10 simulators, but with the latest it doenst seem to work, no matter what Application download.

    I tried with different versions of the Simulator including 10.2.2_0X1444

    The Simulator to load correctly.

    I can browse the internet, so I know I have connectivity,

    I can go on the App World and then choose an application to download.

    The progress bar then moves as it downloads the file.

    However at this point, I'm getting the problem. Once the file is downloaded then just get the message 'Installation pending '.

    Is it possible to get an app in the blackberry world to run on the Simulator?

    answered my own question...

    Of

    https://DevNet.madewithmarmalade.com/questions/14729/test-launch-of-a-BlackBerry-bar-file-on-a-Devic...

    The reason is basically because the Simulator is x 86/intel architecture and we build for ARM (device architecture).

    We want to support the Simulator, but various other tasks (for example Windows Phone) platform support take priority for the forseable future. There are some difficulties to support the Simulator with an internal architecture on our side, graphics drivers, etc..

    Note that because the binaries, you can run in the device Simulator BB10 and aBB10 are different (if you use BlackBerry own SDK, it will compile two different binary, one for each architecture), you would not even test a real construction identical and there is always possibility of issue on the device, you do not see on the desktop.

  • Background is white in the Simulator version 10.1.0.1483's system Z10

    Hi all

    I found a problem. My application is white when running in the simulator of Z10 10.1.x.1483's.

    It is OK in the simulator of Q10. Why the background is white?

    Thank you.

    brad_qqq

    Dark theme is used by default for Q10 because it has OLED that consumes more energy with bright display theme.

    You can force the same pattern for both devices in bar - descriptor.xml, but this is not recommended.

    This thread has more information:

    http://supportforums.BlackBerry.com/T5/Cascades-development/cascade-issue-black-background-on-dev-al...

  • To open the app in the simulator of BB 10 Alpha Dev in debug mode

    Hello

    I develop black berry 10 webworks app. I use the latest version of the sdk provided and the dev alpha 10 blackberry Simulator to run the application. I am also using the ripple chrome emulator to test and debug the application.

    I want to debug the application on the simulator using the browser webkit or something like that, but for some reason I'm not able to do.

    While the application of packing, I inserted the - d option. It says on the bb site which

    "With your application running in the Simulator in a desktop browser, type http://:."

    I tried to but could not see the application in debug mode.

    I tried port numbers, since I was on the apache server

    8080,8181,85...

    Could any body help me with this

    Thank you very much in advance

    See you soon

    Because you added the - d option, it should work very well. All you need to do is put the device/Simulator in developer mode (settings-> Security-> Developer Mode) and I guess you have already done this. In almost all cases, I worked with BB PlayBook and BB10 all what you need to do now is the point of your browser Chrome this URL + port:

    http://:1337
    

    The INVESTIGATION period should not be the problem since you already deployed the app on the Simulator, I guess? So give it a try with the port number and it should work now.

  • Error when, with audio streaming via HTTP to the Simulator

    I use JDE 4.7 and 8900 Simulator.  I'm trying to listen to an MP3 via http to a blackberry app.  When you use the BufferedPlayBack example screen, I get the following error when the data source is trying to open the connection - "net.rim.device.cldc.io.dns.DNSException: error trying to solve.

    When I enter the same URL in the BlackBerry browser on the Simulator, I get the following error: "the selected server returned an error when you try to respond to your request.

    When I enter the same URL in my web browser in my PC, I am able to stream audio and play with QuickTime.

    Why I get this DNSException on the BB and not on my local PC?  The web engine runs also locally.  I know that the BB Simulator does not support rstp.  The Simulator also not does support streaming over http?

    This is the URL I used:

    http://myLocalMachine:8080/myMusic/anAudio.MP3;deviceside=true

    Thanks in advance!

    T

    I found a solution to the question in the thread below.  I increased the connection. MaxNumberOfKBytesToSend = 10240 in the... File MDS\config\rimpublic. Property and so was able to sucessfully stream mp3 to my request.

    http://supportforums.BlackBerry.com/T5/Java-development/increase-MDS-CS-limit-on-http-download-size/...

  • App is load/absent in the Simulator

    I am new to Blackberry programming and that you have just installed the JDE version 6 with the 9700 Simulator. I tried to launch the sample helloworld application and it present or run in the Simulator. Even if I load the application on the file menu, nothing. The Simulator launches as planned and I can navigate through the menus. If I stop the app in the JDE with stop sign, a window entitled "C:\NoSuchFile.java" and it is said in the source code file is not available. Any ideas?

    It has been marked as active. I went with the Eclipse/RIM plug on the way and it works fine, then we can close this question, as far as I'm concerned.

  • Cod files does not not in the Simulator!

    First of all, I must say that development of BlackBerry is probably the most frustrating form of development that I met.

    I can't get my HelloWorld application to run on the Simulator.

    I have successfully built the cod file using eclipse and one build.xml.

    I copied all the output files (including cod file) in the Simulator installation directory manually.  It did not work.

    So I tried to load the java program directly using the Simulator via file > load Java program...

    None of these methods work.  There is no icon in the downloads folder.  My request is not listed in the list of the Application Simulator, BUT he is listed in the list of the Module.

    operating system: Vista

    JDE version: 4.6.0

    IDE: eclipse

    It's maybe a stupid question, but still: your application has an enty point?

  • APPLICATION will not appear on the main menu of the Simulator... Help, please

    Hello everyone,

    I came across this example code and tried to run on the Simulator 9900 and for some reason, the Simulator does not pick up the code. ..

    as the application does not appear on the main menu screen options... so I can not fire at all.

    someone knows why... ID really appriciate the help

    (Note: the simple code opens a new window when clicking on a button)

    Kind regards

    gezzy

    package mypackage;
    
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.FieldChangeListener;
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.component.ButtonField;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.container.MainScreen;
    
    public class FirstScreen extends MainScreen implements FieldChangeListener {
        ButtonField theButton;
    
        public FirstScreen() {
            add(new LabelField("First Screen"));
    
            theButton = new ButtonField("New Screen", ButtonField.CONSUME_CLICK);
    
            theButton.setChangeListener(this);
    
            add(theButton);
        }
    
        public void fieldChanged(Field field, int context) {
    
            if (field == theButton) {
            UiApplication.getUiApplication().pushScreen(new SecondScreen());
            }
    
        }
    
        public class SecondScreen extends MainScreen {
    
            public SecondScreen() {
                add(new LabelField("Second Screen"));
            }
        }
    }
    

    I think you are saying that the application icon will not be displayed on the Simulator? If so, this can help (I had the same problem and what I did):

    1 assuming you are using Eclipse, just run the program (it will be forfeit and display an icon to load for a few seconds on the Simulator).

    2. then go to file-> load BlackBerry Application or theme on the Simulator.

    3 navigate to your compiled COD of the file, then open it.

    4 after a loading icon, the application should appear in the menu.

    If this does not work, try to close the Simulator and do step 1.

    I hope this will help!

  • App won't start with the Simulator

    Hello

    I met a lot of mistakes trying to get that deployed on the Simulator, most of them addressed by other posters.  I use the 0.9.3 beta version of the Simulator.

    However, now I have this problem that I can not find the answer.

    Flash Builder will not launch the application.  The following text is displayed in the console:

    Using the default icon: C:\Program Files (x 86) \Adobe\Adobe Flash Builder 4\sdks\blackberry-tablet-sdk-0.9.2\bin\... \samples\icons\blackberry-Tablet-default-Icon.png
    Package created: C:\Development\Mobile\PuzzletsPlaybook/PromoAppPlaybook.bar
    Picked up JAVA_TOOL_OPTIONS:-Xmx1024M
    Sending request installation and launch...
    Error: Username or password is invalid or not specified or time on the device is out of sync

    I tried this FB parameter to use the Playbook password and not to use it, and fail both ways.

    How can I fix it?  The Playbook must have a pw but I can't start my application.

    Also, I use VM Player as host of Simulator, the Playbook should be run in the Simulator or is it launched by FB?  I tried two ways does not.

    Thank you!

    Hey,.

    It seems that you are using the latest sim but more old SDK. try to update your Tablet OS SDK of AIR and then try to deploy again. using the versions do not match led to mistakes in the past.

    Here is the link to the latest SDK:

    http://us.BlackBerry.com/developers/Tablet/Adobe.jsp

    Good luck!

  • The samples and the Simulator

    Of course miss me configuration here but something despite the (active) configuration and create a simulator, I run as application Tablet and I get

    Package failed: 1
    Error: File or dir does not exist: C:\apps\bbndk-2.0.0-beta1\target\target-override\x86\usr\lib\libbps.so

    It is the same for all the example HelloWorld etc.

    If I create the model opengl application I can run on the Simulator.

    I'm sure that this has been answered, but I'm not so all suggestions accepted with gratitude

    See you soon

    Bob

    H, Bob,

    Just remove the good of your bar file libbps.so - descriptor.xml. You don't need for deployment on the 2.0 OS.

    If you still need to deploy on 1.0.x OS, then it becomes more complicated.

    HTH,

    Christian

Maybe you are looking for