10-03-2008 03:52 AM
Hello,
Through my app I am making a call to a remote server URL. However I get the following in my debug window in the JDE:
tarting App
Started App(122)
Foreground App(122)
FocusHistory: Focus lost; App Home Screen; Component net.rim.device.api.ui.MediaController
Refreshing connection on send
Running refresh
Local port: 19780
FocusHistory: Focus gained; App App; Component App.HelloScreen$2
APN: 'rim.net.gprs'
APN username: 'null'
APN password: 'null'
Connection does not exist
Detected information for 1 GPAK connection(s)
FocusHistory: Focus gained; App App; Com ....
Any idea why I am getting the APN errors? I suspect that is the cause... Ps I am using the simulator with MDS right now.
Thanks,
Chirag
10-03-2008 04:05 AM
Silly questions probably, but we have to rule out the obvious.
What connection suffix are you using for your URL?
Is the MDS actually starting?
I presume you have seen this?
What Is - Different ways to make an HTTP or socket connection
DB-00396
10-05-2008 11:43 PM - edited 10-05-2008 11:43 PM
Hi,
I think I am making a direct call... below is the code snippet:
StreamConnection s = null;
try
{
s = (StreamConnection)Connector.open(SAMPLE_HTTPS_PAGE
HttpConnection httpConn = (HttpConnection)s;
int status = httpConn.getResponseCode();
if (status == HttpConnection.HTTP_OK)
{
// Is this html?
String ctype = httpConn.getHeaderField(HEADER_CONTENTTYPE);
boolean htmlContent = (ctype != null && ctype.equals(CONTENTTYPE_TEXTHTML));
InputStream input = s.openInputStream();
if (status == HttpConnection.HTTP_OK)
{
// Is this html?
String ctype = httpConn.getHeaderField(HEADER_CONTENTTYPE);
boolean htmlContent = (ctype != null && ctype.equals(CONTENTTYPE_TEXTHTML));
InputStream input = s.openInputStream();
byte[] data = new byte[256];
int len = 0;
int size = 0;
StringBuffer raw = new StringBuffer();
while ( -1 != (len = input.read(data)) )
{
raw.append(new String(data, 0, len));
size += len;
}
raw.insert(0, "bytes received]\n");
raw.insert(0, size);
raw.insert(0, '[');
String content = raw.toString();
if ( htmlContent )
{
add(new RichTextField(raw.toString()));
//content = prepareData(raw.toString());
}
// The long operation is the parsing above, after the parsing is complete, shutdown
// the status thread before setting the text (since both threads modify the content
// pane, we want to make sure we don't have the status thread overwriting our data).
// stopStatusThread();
// updateContent(content);
input.close();
}
else
{
add(new RichTextField("response code = " + status));
}
s.close();
}
catch (IOException e)
{
System.err.println(e.toString());
add(new RichTextField(e.toString()));
//updateContent(e.toString());
}
10-06-2008 04:32 AM
As the article I pointed you at says, the method of call is determined by the suffix of the URL you are using. In this code your URL is
SAMPLE_HTTPS_PAGE
We are going to need to know the contents of that URL to determine the connection type.
Are you doing this on the SImulator? If so, I would suggest you start up the appropriate MDS Simulator.
Can you use the Browser on the device to get to the page you are trying to get?
10-06-2008 02:03 PM
Hi,
Sorry, I missed putting that info in.
Yes I am doing this on the simulator and the MDS is working correctly, because I can actually get to websites browsing through the simulator, so i'm pretty sure the internet connection is working.
Here is the STRING:
String SAMPLE_HTTPS_PAGE = "http://www.google.com";
And here is the error in the debug window:
FocusHistory: Focus lost; App Home Screen; Component net.rim.device.api.ui.MediaController
Refreshing connection on send
Running refresh
Local port: 19780
APN: 'rim.net.gprs'
APN username: 'null'
APN password: 'null'
FocusHistory: Focus gained; App App; Component App.HelloScreen$2
Connection does not exist
Detected information for 1 GPAK connection(s)
FocusHistory: Focus gained; App App; Component net.rim.device.api.ui.component.RichTextField
Thanks,
Chirag
10-07-2008 01:02 PM
10-07-2008 01:49 PM
Hi,
I have a try catch clause:...In the exception handling I just throw it to the screen, but I'm not getting any exceptions reported by the application. The only info that I get is in the JDE debug window which lets me know a connection was attempted and failed, then the focus is given back to the application, without and exception thrown. I put some filler Add new richtextfield, into the catch clause, but it doesn't seem like that line is executed.
catch (IOException e)
{
System.err.println(e.toString());
add(new RichTextField("Got here in exception!"));
add(new RichTextField(e.toString()));
//updateContent(e.toString());
}
Thanks,
Chirag
10-07-2008 04:27 PM
Are you creating the connection in its own thread? Please note that connections should not be made on the main event thread.
If this is the case, then the code in your catch block will fail since it is trying to update a screen from outside of the main event thread. Please see this link for a sample.
How to - Update a screen on the Main Event Thread
Article Number: DB-00136
09-22-2010 10:22 PM
ok, now it works, but when I get the application installed, the problems show up again. Could someone tell me what this is and the solution? BTW, the internet connection on device is works fine.
09-23-2010 03:59 AM
Have you done any debugging on device? What exception are you seeing? Does the device have APN information (specific to the carrier involved) set correctly in the Options --> TCP?