BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 10-10-2010, 03:35 AM   #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 Run app background

Please Login to Remove!

Hi all, I want to build an application that run underground and send a httpRequest. I have done this:

Code:
import java.io.IOException;

import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;


public class HttpSender extends Thread {

    private String url;
    
    public HttpSender(String url) {
        // TODO Auto-generated constructor stub
    }
    
    public void run() {
        HttpConnection conn = null;
        try{
            
            conn = (HttpConnection) Connector.open(this.url, Connector.READ, true);
            //conn.setRequestProperty("Content-Type", "image/jpeg");
            conn.setRequestMethod(HttpConnection.GET);
            conn.setRequestProperty("Content-Disposition", "form-data");
            conn.setRequestProperty("Connection", "Keep-Alive");
        }
        catch(Exception e){
            e.printStackTrace();
        }
        finally{
            if(conn != null){
                try {
                    System.out.println("" + conn.getResponseCode());
                    conn.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    
                    e.printStackTrace();
                }  
            }
        }
        super.run();
    }

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

    String getUrl() {
        return url;
    }
}
Code:
import java.io.IOException;

import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;

public class Geopd extends UiApplication
{

    public Geopd() {
        try
        {
            HttpSender hs = new HttpSender("here url");
        }
        catch(Exception ex)
        {
            Dialog.alert(ex.toString());
        }
        
    }

    /**
     * @param args
     * @throws IOException 
     */
    public static void main(String[] args) {
        
        Geopd _geopd = new Geopd();
        
        _geopd.enterEventDispatcher();

    }

}
The program send httprequest in emulator but not in real blackberry

Any suggestion plz?
Offline  
Old 10-10-2010, 09:56 AM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

The simulator (with MDS) emulates a Blackberry that is connected to a BES network.

If you are in the consumer space, then most BB's will not be on this network, so you'll have to determine the type of network and add connection parameters to your URL to request the correct connection type.

If you are an alliance member, then you can utilize BIS-B. Howver, since you are asking this question, I'm going to assume that this is not the case.

So you have several options on most (but not all) BB's:

WiFi
WAP2
Direct TCP
WAP1

I suggest you do a little research on the forum - this is well-covered ground.
Offline  
Old 10-10-2010, 05:05 PM   #3 (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

I use WAP2 as a far as I know, but I dont know how to build the url string. I cheked out this page: supportforums.blackberry.com/t5/Java-Development/Different-ways-to-make-an-HTTP-or-socket-connection/ta-p/445879]Different ways to make an HTTP or socket connectio... - BlackBerry Support Community Forums but I cant use the it coz I have to sign my app or phone. Is there any other way to build the url with WAP2 and without sign?
Offline  
Old 10-10-2010, 07:05 PM   #4 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default

Have a look at this video: Networking Transports II - BlackBerry Support Community Forums
__________________
My other Blackberry is a PlayBook.
Offline  
Old 10-12-2010, 02:03 AM   #5 (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

I cant sign my app but I know Im using WAP 2 so y tried to do this:

String url = "url_link;deviceside=true;ConnectionUID=WAP2";

but my cell doesnt send the request, but it ask me if i want to allow a send from my app.
Offline  
Old 10-12-2010, 07:10 AM   #6 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default

Quote:
Originally Posted by Demian View Post
I cant sign my app but I know Im using WAP 2 so y tried to do this:

String url = "url_link;deviceside=true;ConnectionUID=WAP2";

but my cell doesnt send the request, but it ask me if i want to allow a send from my app.
That is normal behaviour. If you give it permission it should connect.
__________________
My other Blackberry is a PlayBook.

Last edited by hrbuckley : 10-12-2010 at 07:36 AM. Reason: Correction.
Offline  
Old 10-17-2010, 12:25 PM   #7 (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

Quote:
Originally Posted by hrbuckley View Post
That is normal behaviour. If you give it permission it should connect.
I already give it permission but still doesnt connect.
Offline  
Old 10-23-2010, 10:39 PM   #8 (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

Should I have to set deviecside=true if Im using WAP 2?
Offline  
Old 10-24-2010, 05:47 AM   #9 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default

According to the video presentation I linked to, yes.
__________________
My other Blackberry is a PlayBook.
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.