BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 07-22-2008, 10:18 AM   #1 (permalink)
New Member
 
Join Date: Jul 2008
Model: 8330
PIN: N/A
Carrier: Verizon
Posts: 8
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default https connection / first development attempt

Please Login to Remove!

Hey guys. This is my first time developing for BB, and I know there's a lot of stuff I need to worry about (threading, etc), but for now I'm just trying to get some basic functionality up.


void getViaHttpsConnection(String url)
throws java.io.IOException
{
javax.microedition.io.HttpsConnection c = null;
java.io.InputStream is = null;


try
{
c = (javax.microedition.io.HttpsConnection)javax.micro edition.io.Connector.open(url);

c.setRequestMethod("GET");

is = c.openInputStream();
c.close();

}
finally
{

}

}

The URL could be anything; the simulator just locks up. A couple of questions:

1) I'm using Eclipse, and can't seem to trigger breakpoints during debug cycles.

2) How do I tell (or do I need to?) the httpconnection to use wifi or cell or xyz?

3) This is running on my debugger, so is there anything special I need to know when it comes to network access?
Offline  
Old 07-22-2008, 11:56 AM   #2 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2008
Location: Chennai
Model: 8130
PIN: N/A
Carrier: AIRTEL
Posts: 51
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Use separate thread for HttpConnection...
__________________
Jayaseelan.V
Mobile Application Developer
INDIA.
Offline  
Old 07-22-2008, 12:25 PM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: Dec 2005
Model: 8310
Carrier: Rogers
Posts: 138
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

A couple pieces of advice:

As Jayaseelan says, use a separate thread for I/O connections. The reason is because Connector.open and openInputStream are blocking calls. If you initiate these calls from the event dispatch thread, you'll hang it.
Offline  
Old 07-23-2008, 08:46 AM   #4 (permalink)
Thumbs Must Hurt
 
Join Date: Apr 2006
Location: Boston
Model: 8900
Carrier: AT&T
Posts: 98
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi!

Network access using a BlackBerry simulator does not exist unless/until you also launch the MDS simulator. The BlackBerry JDE comes with a Preferences dialog that has a "Simulator" panel which provides a checkbox indicating "Launch Mobile Data Services (MDS) with simulator". If you're using Eclipse, I don't know what (or whether there is a) setting to do the same thing. You can always launch the MDS simulator by hand from the Start menu.

The MDS simulator comes with a configuration file in its "config" subdirectory. The configuration file "rimpublic.property" is a collection of settings for a variety of different things that MDS allows you to do. If you're doing this behind a corporate proxied firewall, you'll need to set the proxy settings in the configuration file to do the right thing. In addition, if you're setting up to do HTTPS, you may want to configure the MDS simulator to blindly accept any untrusted server - otherwise, you may have to deal with certificate acceptance and importing and all kinds of excitement like that (I've got a thread that I started back in April or May regarding the importing of certs on a handheld and just how challenging that process is).

Good Luck!

Cheers,

karl
__________________
Karl G. Kowalski
---------------
Owns a RAZR
Develops for BlackBerry
So next phone will be........an iPhone 3G!
Offline  
Old 07-23-2008, 08:48 AM   #5 (permalink)
Thumbs Must Hurt
 
Join Date: Apr 2006
Location: Boston
Model: 8900
Carrier: AT&T
Posts: 98
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

And one thing more:

Once you (think you) have the MDS simulator running/configured correctly, launch a BlackBerry simulator and try to use the browser to go to Yahoo or Google. You should see a couple of things. The MDS simulator command-window will go all kinds of crazy and spew text in all directions, making it look like a Matrix display screen (okay, not so much). And your browser should download the proper HTTP from the web site and display it.

Cheers,

karl
__________________
Karl G. Kowalski
---------------
Owns a RAZR
Develops for BlackBerry
So next phone will be........an iPhone 3G!
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.