can upload from a simulator but cant on real device

          /*
             * HTTP Connections
             */
            connDesc = connFact.getConnection(tempfile);
            httpConn = (HttpConnection)connDesc.getConnection();
            try {
                if(httpConn.getResponseCode() == HttpConnection.HTTP_OK)
                {
                    StatusScreen._filestatus.setText(localfilename);
                    int _fileSize = (int)httpConn.getLength();
                    StatusScreen._downstat.setText(Integer.toString(_fileSize));
                    /*
                     * File connection
                     */
                    FileConnection file = (FileConnection) Connector.open(appNameDir + localfilename , Connector.READ_WRITE);
                    file.create();
                    file.setWritable(true);
                    DataOutputStream oS = file.openDataOutputStream();                  

                    // set local file size
                    size = -1;
                    size = _fileSize;
                    // set downloaded file
                    downloaded = 0;
                    DataInputStream iS = httpConn.openDataInputStream();
                    while(fileDownloadStatus == 0)
                    {
                        byte[] buffer;
                        if(size - downloaded > MAX_BUFFER_SIZE)
                        {
                            buffer = new byte[MAX_BUFFER_SIZE];
                        }
                        else
                        {
                            buffer = new byte[size - downloaded];
                        }
                        int read = iS.read(buffer);
                        if(read == -1)
                        {
                            break;
                        }
                        oS.write(buffer, 0, read);
                        downloaded += read;
                    }
                    iS.close();
                    oS.close();
                    file.close();

I have a problem downloading a real device file

on real device the size of the file to the file will always be-1

but on the Simulator, he will get the actual size...

is there a problem with my code?

There's a thread sticky in this forum, created by peter_strange:

HTTP code and Access BIS-B connection example

In my opinion, it is better that most of the books of BlackBerry - read it!

The isssue is not exactly with your code - it is with the different ways in which the BlackBerry can connect to the Internet. Unfortunately, even a 'simple' download becomes a non-trivial task on it.

See if playing with suffixes connection solve the problem - it could, it could not

Tags: BlackBerry Developers

Similar Questions

  • 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

  • Can print from other applications but not PS

    I'm trying to print from my Macbook Pro 2011 to a brother 2240 laser printer. I can print from other applications, but not of Socialist Party (CC 2014). In the preferences system, the printer shows as online, but in the PS print dialog box, when I click on the printer icon bit to the right of the selected printer, something of utility Brother appears and displays offlilne. But if I go to TextEdit I can print to the printer. Any ideas?

    Nuke your preferences to Photoshop and Photoshop to create new preferences files by pressing Command + Option + shift as soon as you launch Photoshop, keeping them pressed until you see a dialog box that you go click on Yes the force.

  • Event Swipe works in the Simulator, but not on the device

    I'm using panels on my 9900 and I have 4 panels that the user will slide back and forth similar functioning BB app world, changing the summary of comments on signs etc..

    My expection who was up and down for scanning of touch screen functions and the touchpad has the same function by default, that is to the left and right slide on the screen should also be identical to forehand and left on the block to tack. But it does nothing for the panels when you use the trackpad.

    So I replace NavigationMovement and and can see the touchscreen and the track pad to generate a NavigationMovement event with +/-x according to the direction slide. So I'm first puzzled why hit swiping the trackpad on the left and right triggers not the same behavior by hitting swiping left and right on the touch screen.

    Accept that as a limitation of the API, I added my own features to NavigationMovement to inject a key event when user left or right on the trackpad moves. As follows:

    EventInjector.TouchEvent [] moveEvents = new EventInjector.TouchEvent [7];

    moveEvents [0] = new EventInjector.TouchEvent (TouchEvent.MOVE, 420, -1, -1, 60-1);
    moveEvents [1] = new EventInjector.TouchEvent (TouchEvent.MOVE, 360, 60,-1, -1, -1);
    moveEvents [2] = new EventInjector.TouchEvent (TouchEvent.MOVE, 300, 60,-1, -1, -1);
    moveEvents [3] = new EventInjector.TouchEvent (TouchEvent.MOVE, 240, 60,-1, -1, -1);
    moveEvents [4] = new EventInjector.TouchEvent (TouchEvent.MOVE, 180, 60,-1, -1, -1);
    moveEvents [5] = new EventInjector.TouchEvent (TouchEvent.MOVE, 120, 60,-1, -1, -1);
    moveEvents [6] = new EventInjector.TouchEvent (TouchEvent.MOVE, 60, 60,-1, -1, -1);
    EventInjector.TouchEvent.injectSwipeGesture (480, 60, moveEvents);

    It works perfectly in the Simulator, but on the device, there is no movement at all. So I thought that maybe the touchpad on the Simulator is more sensitive than on the real device, so I added a menu item to perform the injection above. Again, this works perfectly on the Simulator, but nothing on the device.

    Has anyone tried this brain left and just before the injection?  Up and down the injection works perfectly on the device.

    Have you enabled event injection in request permission settings for your application?  It is disabled by default.  You can do so by going to Options-> Application, select your application and click on change permissions.  You can also request these permissions programmatically using the class ApplicationPermission.

  • Can deploy app in the Simulator, but not to the device

    Sorry about this newbie question, but how is it that a simple HelloWorld application compiled in Eclipse runs just fine on the Simulator, but cannot be installed on a 8320 Curve by the Blackberry Desktop Software?

    I use the latest version at all.  The message returned by the desktop software is:

    ! There was an error importing files.
    No additional applications can be found. Your file can
    contain applications that already exist in the list of applications,
    are not compatible for your device, or errors.

    However, I am able to deploy the application on the handset using the command line tool:

    C:\Eclipse\plugins\net.rim.ejde\vmTools\JavaLoader.exe -usb load \workspace\HelloTest\deliverables\Standard\5.0.0\HelloTest.jad
    

    This installs the application, which then runs correctly on the device.  I can then reload the list of app on the Blackberry Desktop Software tool and it shows HelloTest, but under the properties of the Application-> dependencies it says:

    "Application not available (net_rim_cldc).

    It seems that some dependence crept in the generation of the application and that confuses the desktop tool.  The curve is running 4.5 OS.

    Should I just throw this office tool, or how can I clean the application so that it installs correctly?  Obviously, this is just foreplay before building a much broader application, and I wish I had these little glitches will hamper ASASP.

    Thanks for any help!

    You should be able to download a plugin 4.5 on the site to update. Go to "help > install new software" to open the screen of software available. If you have not yet done so, add the updated BlackBerry site to your Eclipse configuration:

    1. Click on "available software Sites.
    2. Click on the button 'Add '.
    3. Enter a name such as 'BlackBerry update location' and set the location http://www.blackberry.com/go/eclipseUpdate/3.5/java
    4. Click OK, then OK again to return to the screen of the software available

    The 'working with' menu drop-down, select the location of BlackBerry Update (or whatever you named it). Expand the BlackBerry Java plug-in category and you should be able to select an appropriate plug-in version.

  • image in SVG shows it on the Simulator, but not on the device

    Hi all

    I put theelement in an SVG file with an image that I pick up store or the SD card. I can see the image set on the Simulator, but am not able to see it on the device.

    Here is the code snippet I definition of the element in the image:

    SVGElement "newelement" = (SVGElement) _document.createElementNS (SVG_NAMESPACE_URI, "image");
    newElement.setTraitNS (XLINK_NAMESPACE_URI, "href", dittos);
    newElement.setFloatTrait ("x", 0);
    newElement.setFloatTrait ("y", 0);
    newElement.setFloatTrait ("width", Display.getWidth ());
    newElement.setFloatTrait ("height", Display.getHeight ());
    _svg. AppendChild (newelement);
    Invalidate();

    Thanks in advance.

    ~ Shri

    It was with the size of the Image. Too big a picture and the device wont set it to SVG canvas.

    If the scale down the image and set the image if you want to set asin SVG.

  • Private opens in the Simulator, but not on the device

    Hello world

    I have a BlackBerry Tour 9630 (4.7.1.61). I'm running the 4.7.0 Simulator in Eclipse.

    Does anyone know why my application would open up a private in the Simulator without problem, but the browser does not open on my real device? I get no error on the device, it just goes to the next screen. I confirmed that the internet works on the device, and I don't see why use only the type of browser BIS would be a problem (I also tried BES).

    Here is my code:

    UiApplication.getUiApplication().invokeLater(new Runnable() {
        public void run() {
    
        BrowserSession session = BrowserLocator
            .createBrowserSession(BrowserLocator.BROWSER_TYPE_BIS);
                if (session != null) {
                    session.displayPage(loginUrl);
                }
    
        AuthorizeScreen authorizeScreen = new AuthorizeScreen();
        UiApplication.getUiApplication().pushScreen(authorizeScreen);
        UiApplication.getUiApplication().popScreen(OAuthScreen.this);
        }
    });
    

    Thank you!

    Thanks for your help.

    The session was to return null. I was able to reproduce this behavior in the simulator using a different type of browser not supported by the service books. Finally, I removed my own BrowserLocator() class (for the call of a certain browser) and replaced by the BrowserSessionFactory() provided in the JDE samples. I now have the browser on the opening device.

    What is the safest Bet, to use the default browser of the device, or use a browser BIS?

    Thank you!

  • my app works in ripple, but not in real device :(

    I made a request of 'fitness' with webwork development,

    It works very well in ripple and build, with success.

    but BB app world answer me it shows a blank page so it rejected, & I shocked when seen on real device from my friend did not work and the really white page

    I do not know

    how it works well on the training and do not work on the real device!

    Good luck.  If you're stuck on how to do it, here is the complete documentation on how to perform debugging using Web Inspector:

    https://developer.BlackBerry.com/HTML5/documentation/web_inspector_overview_1553586_11.html

  • I have a hp officejet 4215v all-in-one I can print from my computer, but not for my printer

    I'm unable to copy the documents from my printer.  I am able to copy from the computer.  I also can not uninstall and reinstall printer because it does not appear in Add/Remove programs.

    I'm sorry you have a problem with the printer.

    Do you receive an error message when you try to copy a document from the printer itself?

    If you are not able to print/copy of the printer itself, uninstalling and reinstalling will not help. It would be a problem with the hardware with the printer.

    Try to print a self-test page or printer the printer status report.

    Perform a hard reset. Unplug the power cord at the back. Leave for 30 seconds and plug it back.

  • on my computer, I can print from my photo, but it doesn't show me any image from another region, program prints, I check my printer and my printer in find, don't know what to do

    my printer will only print photo image and will not print from another program, did a teamwork tech on my computer and I don't know what has been subscribed, but whatever it is is cusing my computer don't not to print images, need help

    Hi clrfryeclijane,

    (1) who is the manufacturer of your printer?

    First, print a test page and check if it prints graphics as expected

    Print a test page
    http://Windows.Microsoft.com/en-us/Windows-Vista/print-a-test-page

    Method 1: Put the computer to an earlier point in time where everything worked well and test it. To do this, follow the steps mentioned in the link below

    What is system restore?

    http://Windows.Microsoft.com/en-us/Windows-Vista/what-is-system-restore

    Method 2: Run the fixit available in the link below and check if that makes a difference

    Solve printer problems

    http://Windows.Microsoft.com/en-us/Windows-Vista/troubleshoot-printer-problems

    If the problem persists,

    Method 3: Download and install the latest version of the printer software (and drivers) on the device manufacturer's website.

    Thank you, and in what concerns:

    Ajay K

    Microsoft Answers Support Engineer

    ---------------------------------------------------------------------------------------------------------
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • The screen on the Simulator, but not on the device loads

    Hi all

    This issue is driving me crazy.

    The problem: I added a menu item in the email application. When the user clicks on the menu, I load a pop-up screen and get the entry user, then save it. This works quite well on my Simulator (8310 v4.5). But when I load in my camera (8310 v4.5), is not.

    I can't understand where is the problem. Your entries please.

    Note: I checked with the record menu item. I added a warning msg before loading of the screen. The alert is displayed, while the screen does not load. (The screen is a separate category in the same menuitem file, I have class instantiaite inside the application menuitem run() method).

    Sorry, I was in a hurry, so just wrote a very brief answer.  Unusual for me!

    Take a look at this:

    http://supportforums.BlackBerry.com/T5/Java-development/how-do-I-debug-on-a-live-device/Ta-p/446842

    There are other tips on the forum that you will probably find through research, should he not help.

  • KSOAP2 working on the Simulator, but failed on the device. Help, please!

    Hi all. Please, I need support on this issue.

    I have a request of KSOAP2 running which:

    1) Œuvres ALLWAYS on the Simulator (9700 Simulator)

    2) FAILS on the device when you use 3 G Internet Link

    3) work on the device when hard reseting it and directly using Wi - Fi link (if you switch to 3 G, it starts failing).

    When it do I get the following error:

    type of org.xmlpull.v1.XmlPullParserException:Unexpected (position: TEXT SocketException:...@1:33 in java.io.InputStreamReader@hexhere)

    Some other times I get an IO error faced:

    net.rim.device.cldc.io.ippp.SocketBaseIOException: Connection timed Out

    The funny thing is that it works through 3 G as 1 in 40 times... it seems that 3 G connection is too slow to KSOAP2 to work properly, or something like that. The complex type is small (8 strings).

    My webservice is a webservice VB.NET located on the production IIS server. It works well because it responds to any request of Simulator.

    Additional data:

    -Other Internet applications of device (such as the Internet browser) works well through 3G even when my application does not always succeed. Coverage of 3G service is excellent.

    -J' use JRE 5.0.0.

    -Device is a BlackBerry Bold 9700

    -Webservice is written in VB.NET in the production on the Internet Server, and it works perfectly because it responds to each request of Simulator.

    -J' use javaloader.exe to deploy the cod to the device files (both, ksoap library cod and cod of my project)

    -L'application is not signed.

    -Once the application starts breaks down (when you switch to 3G) it maintains in default if you return to the WiFi again.

    Here is my code:

    String res="";
    boolean error=false;
    Vector seguimientos = null;
    
    SoapObject m_Soapobject=new SoapObject("urn:tempuri", "GetSeguimientos");
    SoapSerializationEnvelope m_Envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
    m_Envelope.encodingStyle = SoapSerializationEnvelope.ENC;
    
    m_Soapobject.addProperty("strInstance", "r2sistemas");
    m_Soapobject.addProperty("user", "myuser");
    m_Soapobject.addProperty("password", "mypassword");
    m_Soapobject.addProperty("comercialId", "3");
    
    m_Envelope.addMapping("urn:tempuri/encodedTypes", "Seguimiento", new Seguimiento().getClass());
    m_Envelope.bodyOut = m_Soapobject;
    m_Envelope.setOutputSoapObject(m_Soapobject);
    
    HttpTransport ht = new httpTransport("http://www.productionserver.com/service1.asmx");
    ht.setXmlVersionTag("");
    
    try {
        ht.call("urn:tempuri/GetSeguimientos", m_Envelope);
        SoapObject respuesta=(SoapObject)m_Envelope.bodyIn;
        seguimientos=(Vector)respuesta.getProperty(0);
        } catch (IOException e) {
        error=true; res="IO Problem: " + e.toString();
        } catch (XmlPullParserException e) {
        error=true; res="XMLParser problem: " + e.toString();
        }
    
    if(error!=true) {
        Seguimiento seg=(Seguimiento)seguimientos.elementAt(1);
        res=seg.Comentario;
        }
    
    this.add(new LabelField("aa"+ res));
    

    I read on this forum that ksoap2 cannot treat the http error messages. You must download the KSOAP source and change it to do this. Something like ServiceConnectionMidp. The message is this: link

    I use a port KSOAP2 library: ksoap2-j2me-core-prev - 2.1.2.jar, like I said it works fine on the Simulator. I tried to download the source code of KSOAP to debug in the failing methods, but was unnable to do compile ok on Eclipse.

    I really am stuck at this point. Please, any help would be great.

    Thank you in advance.

    Ok. Further reading took me to the problem.

    AFAIK, there are 5 ways to connect to web addresses from a BlackBerry device.

    Of course, the BB Simulator uses one that works with my WS. When my BB is connected via wifi it works as well. However, when I use the 3g from my device connection, I should mention the destinies of correct connection on the connection URL parameters.

    That's what I did:

    I read this: 1 Source

    And this (Spanish): Source 2

    Of course, I noticed that my BB is connected to a BES company, I must indicate the correct ConnectionUID to my address book of device on the connection string. So now the line in my code is:

    HttpTransport ht = new HttpTransport("http://www.address.com/service1.asmx;deviceside=false;ConnectionUID=YOURCONNECTIONUID");
    

    To find your UID connection, take your device, go to Options - Advanced Options - service book. Choose a book of service applications that connects successfully on your device (in my case Blackberry Internet Browser service), open it and copy the ConnectionUID. Then, paste it in the connection string.

    Now, it works great!

    My next challenge is to find connection string parameters correctly so that the application works on any device, not only on my ones company BES.

    Someone knows what should be the standard setting?

    I hope that my help of inquiry.

    P.S. still cannot complete successfully ServiceConnectionMidp...

  • my world event working on the Simulator, but not on the device

    Hi guys,.

    I'm using BB bold 9000. I have attached directly to the device and debugging. I'm getting "background switch detected for myapp (261) that does NOT have the tunnels open - defocus is NOT called" on the device debugging. but it works fine on the Simulator (my ultimate task is slaughtering an application from another application) any idea?

    Thank you

    Thank you guys, it's worked.

  • App works on the Simulator, but not on the device

    Just try to run the helloworlddemo app compiles fine and works on the Simulator without problem. All I get on the device is an icon of the application that does nothing when clicked.

    I had read this might have to do with the version of the JDE is high for the operating system on the device, but I'm running JDE 6.0.0.37 and the operating system on the device is 6.0.0.666

    I tried with my own app first, compiled, signed it and get the same result as helloworld, then its certainly some mounted sort of question but I have no idea of what

    Thank you

    Sheldon

    Thought of it - was to set the permission of application so that all 3 items were "allow."

  • sample application is running on Simulator, but not on the device

    I created the 'Hello World' example and ran on the Simulator.  It works fine in there.  I used JavaLoader put the cod on my phone.  The icon is on the phone, but when I click it, nothing happens.  What I am doing wrong?

    JavaLoader gave me other errors.  So far, creating a files .alx file and installation with the Office appear to be more successful.  I think I'll use that in the future.

    Steven

Maybe you are looking for