BlackBerry Forums Support Community
              

Closed Thread
 
LinkBack Thread Tools
Old 01-11-2011, 11:20 PM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Oct 2010
Model: 8100
PIN: N/A
Carrier: Software
Posts: 17
Post Thanks: 1
Thanked 0 Times in 0 Posts
Default HttpConnection doesntwork

Please Login to Remove!

Hi, Im trying to send a http request with this code:

Code:
public class HttpSender extends Thread {

	private String url;
	private String reply = "";
	
	public String getReply() {
		return reply;
	}

	public void setReply(String reply) {
		this.reply = reply;
	}

	public HttpSender(String url) {
		this.url = url;
	}
	
	public void run() {
		HttpConnection conn = null;
		try{
			
			ApplicationManager myApp = ApplicationManager.getApplicationManager();
		     while(myApp.inStartup()) {
		         try {
		             this.sleep(2000);
		         } catch(Exception e) { 
		             // Catch Exception
		         }
		     } 
			
		     
			conn = (HttpConnection) Connector.open(this.url, Connector.READ_WRITE, true);
		    conn.setRequestMethod(HttpConnection.GET);
		    conn.setRequestProperty("Content-Type","//text plain");
		    conn.setRequestProperty("Connection", "close");
		
		}
		catch(Exception e){

		}
		finally{
		    if(conn != null){
		        try {
					System.out.println("" + conn.getResponseCode());
					conn.close();
				} catch (IOException e) {			
					e.printStackTrace();
				}  
		    }
		}
		super.run();
	}

	void setUrl(String url) {
		this.url = url;
	}

	String getUrl() {
		return url;
	}
}
Code:
public class Utilitarios
{
public static String GetConnectionID()
	{
		ServiceBook sb = ServiceBook.getSB();
		ServiceRecord[] records = sb.findRecordsByCid("WPTCP"); 
		String uid = null; 

		for(int i=0; i < records.length; i++) 
		{
		    //Search through all service records to find the 
		    //valid non-Wi-Fi and non-MMS 
		    //WAP 2.0 Gateway Service Record.
		    if (records[i].isValid() && !records[i].isDisabled()) 
		    {

		        if (records[i].getUid() != null && records[i].getUid().length() != 0) 
		        {
		            if ((records[i].getUid().toLowerCase().indexOf("wifi") == -1) &&
		                (records[i].getUid().toLowerCase().indexOf("mms") == -1))
		            {
		                    uid = records[i].getUid(); 
		                    break;
		            }
		        } 
		    }
		}

		if (uid != null) 
		{
		    return ";deviceside=true;ConnectionUID=" + uid;
		}
		else
		{
		    return "";
		}
	}

}
and for sending request...


Code:
String url = "http://www.xxxxxx.com/xxxxx/index.php?Page=BB&Action=Reg&imei=334&longitud=1&latitud=333"+Utilitarios.GetConnectionID();
		HttpSender hs = new HttpSender(url);
		hs.run();
This code works fine for a bb (I dont remember model) and bb 8100 but it doesn't work for a 9300 :S. It's supossed Im getting the right connection string with Utilitarios class and GetConnectionID method. Any idea why it happens?.


Thanks,

Demian
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

Similar Threads for: HttpConnection doesntwork
Thread Thread Starter Forum Replies Last Post
How can i use httpConnection with MDS in blackberry device thet Developer Forum 1 11-04-2010 06:33 AM
java.io.IOException: Bad DNS address - in opening a HttpConnection Shreyas Developer Forum 0 05-17-2010 06:40 AM
Httpconnection Post method problem?? tramorgan Developer Forum 3 04-22-2010 09:59 PM
HttpConnection response problem PashaCosmos Developer Forum 1 02-21-2008 09:29 AM
HTTPConnection fails for large data bschuhma Developer Forum 3 06-24-2005 07:22 PM

HP Agilent Keysight E2430A Memory Expansion Interface
$58.0
HP Agilent Keysight E2430A Memory Expansion Interface pictureALLEN BRADLEY 1747-M11 SER. B NEW EEPROM MEMORY MODULE 1747M11
$80.0
ALLEN BRADLEY 1747-M11 SER. B NEW EEPROM MEMORY MODULE 1747M11 picture10pcs 25x25x5mm Aluminum Heatsink 25*25*5mm Heatsinks for memory CHIP CPU GPU IC
$5.88
10pcs 25x25x5mm Aluminum Heatsink 25*25*5mm Heatsinks for memory CHIP CPU GPU IC picture1Pcs NAND512W3A2CN6 Nand Flash Memories Tssop
$6.25
1Pcs NAND512W3A2CN6 Nand Flash Memories Tssop pictureAllen Bradley, SLC 500, 1747-M13, 64K Flash EEPROM Memory, Works Great
$45.0
Allen Bradley, SLC 500, 1747-M13, 64K Flash EEPROM Memory, Works Great picture






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