Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 14
Registered: ‎10-20-2012
My Device: Torch 9800
My Carrier: airtel

Application is not running only on 9300

Hi all,

I am working on an application targeted for BlackBerry OS 5 and 6 and it is in last phases of development. During the testing of the application on different devices,we found that the application is not running on Curve 9300. It gets installed properly and starts properly but it halts on loading screen and does not move forward. On loading screen, I am retreiving data from internet in background. From the logs I found that, my web service request to the server gets HTTP_OK 200 response message in return but nothing after that. This behaviour is shown only on 9300 while other devices on which the application is tested(9800, 8520), the application is running absolutely fine. I have tested the app on two 9300 models and both the devices show same beahaviour. The devices were properly connected to the internet (wi-fi or 3G) and other downloaded applications were running fine on them. Please help in this regard.

 

Thanks in advance,

Paramvir Singh

Trusted Contributor
Posts: 141
Registered: ‎02-15-2012
My Device: 9800
My Carrier: Airtel

Re: Application is not running only on 9300

Hi paramveer,

 

Debug the application with your device and let me know the issue/exception what you got??

Highlighted
Contributor
Posts: 14
Registered: ‎10-20-2012
My Device: Torch 9800
My Carrier: airtel

Re: Application is not running only on 9300

Hi Ankit,

Thanks for the reply. I am getting IOException while trying to extract the response from the HttpConnection after the web-service cal.

The IOException occurrs here:

InputStream is = conn.openInputStream();

 

where'conn' is HttpConnection.

 

regards,

Paramvir Singh

Trusted Contributor
Posts: 141
Registered: ‎02-15-2012
My Device: 9800
My Carrier: Airtel

Re: Application is not running only on 9300

Sorry, I liked previous post by mistake.

 

Paramvir, I want to ask that are you using SOAP webservices??

 

And please send me whole method's code using for webservices calling..

Contributor
Posts: 14
Registered: ‎10-20-2012
My Device: Torch 9800
My Carrier: airtel

Re: Application is not running only on 9300

Hi Ankit,

Yes, here is the code I am using for making the web service call.

 private void http() {

        HttpConnection conn = null;
        OutputStream out = null;
        int responseCode;

        try {
        	
        	String connectionString=NetworkSelector.getConnectionString();
        	if(connectionString!=null){
        		conn = (HttpConnection) Connector.open(url+connectionString);
                conn.setRequestMethod(requestMode);//setting method: POST
                
                out = conn.openOutputStream();//getting out stream
                out.write(data.getBytes());
                out.flush();
                responseCode = HttpConnection.HTTP_OK;
        		
                if (responseCode != HttpConnection.HTTP_OK) {
                	getResponseContent( conn );
                    taskSuccessful = false;
                    responseContent = null;
                } else {
                    taskSuccessful = true;
                    getResponseContent( conn );
                }
        	}else{
                taskSuccessful = false;
        	}
        	
        	notifyTask();
        } catch (IOException e) {
            taskSuccessful = false;
            notifyTask();
        } 
    }
	
	private void getResponseContent( HttpConnection conn ) throws IOException {
        InputStream is = conn.openInputStream();

		byte[] data = new byte[20];
		int readLength = 0;
		int size = 0;
		StringBuffer raw = new StringBuffer();
		while (-1 != (readLength = is.read(data))) {
		    String received = new String(data, 0, readLength);
		    raw.append(received);
		    size += readLength;
		}
		conn.close();
		String response = raw.toString();
		try {
    		responseContent = new String(response.getBytes("UTF-8"));
    	} catch (UnsupportedEncodingException e) {
    		responseContent = response;
    	}		
    }

 Where, 

NetworkSelector.getConnectionString();

returns ";deviceside=true" or ";interface=wifi" depending on the device info.

Other developers have also reported same kind of probelms, and the answers to their problem suggest that the problem is with the connection string we use. Please suggest which algorithm I should use to choose the connection string.

 

Thanks,

Paramvir Singh

Trusted Contributor
Posts: 141
Registered: ‎02-15-2012
My Device: 9800
My Carrier: Airtel

Re: Application is not running only on 9300

[ Edited ]

Hi Paramvir,

Use the following code for connection string to add at URL:


public static String getConnectionString() {
/**
* This method returns connection string depends on available Internet
* connection(Wi-Fi, MDS etc.)
*/
String connectionString = null;
// Simulator behavior is controlled by the USE_MDS_IN_SIMULATOR
// variable.
if (DeviceInfo.isSimulator()) {
GlobalMethods.Log("Device is a simulator and USE_MDS_IN_SIMULATOR is true");
connectionString = ";deviceside=false";
}
// Wi-fi is the preferred transmission method
else if (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED) {
//GlobalMethods.Log("Device is connected via Wifi.");
connectionString = ";interface=wifi";
}
// Checking whether the carrier network is the only way to connect
else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_DIRECT) == CoverageInfo.COVERAGE_DIRECT) {
GlobalMethods.Log("Carrier coverage.");
String carrierUid = getCarrierBIBSUid();
if (carrierUid == null) {
// Has carrier coverage, but not BIBS. So use the carrier's TCP
// network
GlobalMethods.Log("No Uid");
connectionString = ";deviceside=true";
}
else {
// otherwise, use the Uid to construct a valid carrier BIBS
// request
GlobalMethods.Log("uid is: " + carrierUid);
connectionString = ";deviceside=false;connectionUID=" + carrierUid;
}
}
// Check for an MDS connection instead (BlackBerry Enterprise Server)
else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS) {
GlobalMethods.Log("MDS coverage found");
connectionString = ";deviceside=false";
}
// If there is no connection available abort to avoid bugging the user
// Unnecessarily.
else if (CoverageInfo.getCoverageStatus() == CoverageInfo.COVERAGE_NONE) {
GlobalMethods.Log("There is no available connection.");
}
// According to theory, all connection types are covered so this
// shouldn't be reachable.
else {
GlobalMethods.Log("no other options found, assuming device.");
connectionString = ";deviceside=true";
}
return connectionString;
}
/**
* Looks through the phone's service book for a carrier provided BIBS
* network
*
* @return The uid used to connect to that network.
*/
private static String getCarrierBIBSUid() {
ServiceRecord[] records = ServiceBook.getSB().getRecords();
int currentRecord;
for (currentRecord = 0; currentRecord < records.length; currentRecord++) {
if (records[currentRecord].getCid().toLowerCase().equals("ippp")) {
if (records[currentRecord].getName().toLowerCase().indexOf("bibs") >= 0) {
return records[currentRecord].getUid();
}
}
}
return null;
}

You have just to use: URL = URL + getConnectionString();


Please press like if you satisfied with the post.

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Application is not running only on 9300

I suspect that this problem is related to the connection method used and/or the capability of the device rather than being 9300 specific.

 

You say:

InputStream is = conn.openInputStream();

is throwing an IOException.  What is the detail of the exception (do a toString() on the Exception.  This will give a better clue to what the problem actually is. 

 

Can you also tell us what connection method (WiFi, BES, ..) is being used in this case.  Is this the same as the device's that it works on?

 

At this stage I do not think that looking at the source will help, especially if the same source is working on other devices.