Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7428221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:42:37+00:00 2026-05-29T08:42:37+00:00

I want call a url and get the response data from the url from

  • 0

I want call a url and get the response data from the url from my Blackberry App. For that, I am using HttpConnection. Here is the code I am using:

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;

public class TestApp extends UiApplication {

   private MainScreen _mainScreen;

   private static TestApp _app;

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

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

       _mainScreen.add(testField);

       pushScreen(_mainScreen);

       HttpConnection c = null;
       DataInputStream dis = 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");
        dis = c.openDataInputStream();
        System.out.println("4");
        int len = (int)c.getLength();
        if (len > 0) {
            byte[] data = new byte[len];
            dis.readFully(data);
        } else {
            int ch;
            while ((ch = dis.read()) != -1) {
                //...
            }
        }
       } catch(Exception e){
           e.printStackTrace();
       }finally {

           try {
                if (dis != null)
                    dis.close();
                if (c != null)
                    c.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            catch(NullPointerException e) {
                e.printStackTrace();
            }
       }

   } 

    public static void main(String[] args) {
         _app = new TestApp();
         _app.enterEventDispatcher();

  }  
}

When I try to run the code in simulator, I am getting ‘0’, then ‘1’ and after that after long time ‘No stack trace’ is appearing in debug window and as soon as the text is appearing, the level app with the text becomes visible in the simulator screen. There is no problem in the internet connection in simulator, I have set up the Wi-Fi and I have tested that I can open any website in the browser. What is problem in my code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T08:42:38+00:00Added an answer on May 29, 2026 at 8:42 am

    MDS has to start for internet access, it will work as interface between Simulator and desktop internet connection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to retrieve data from restful webservice that returns xml. I'm using phonegap.
I want to get xml data from google server using it's API. so, i
I want to call my .NET code from unmanaged C++. My process entrypoint is
I have an ajax call as below: $.ajax({ type: GET, url: process.php, data: dataString,
I want to call a url with passing some parameter and i want to
I want to call a web service, but I won't know the url till
I want to call a function from a .NET DLL (coded in C#) from
I want to call a c# function from my javascript function. I have a
I want to call some RESTful web services from a J2ME client running on
I want to call an ASHX file and pass some query string variables from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.