Connection network in Smartphone problem

Hello

I have read through some networking related tutorials, KB and support forums and have developed this code:

public class GetURL implements Runnable, Stoppable{

    private String _url = null;
    private boolean _stop = false;
    private Object _notifyObject = new Object();
    private String _responseText = null;
    private int _responseCode = 0;

    private URLRequestedListener _ul;

    public GetURL(String urlToGet, URLRequestedListener ul) {
        _url = Utils.encodeUrl(urlToGet);
        _ul = ul;
    }

    public void run() {
        HttpConnection httpConn = null;
        StreamConnection s = null;

        try {

            httpConn = Utils.getConnection(_url, s);

            if ( _stop ) { return; }
            _responseCode = httpConn.getResponseCode();
            if ( _stop ) { return; }

            //fetch the content of the URL
            if (_responseCode == HttpConnection.HTTP_OK) {
                InputStream input = httpConn.openDataInputStream();

                byte[] data = new byte[256];
                int len = 0;
                StringBuffer raw = new StringBuffer();

                while (-1 != (len = input.read(data))) {
                    if (_stop) {
                        if(httpConn != null) httpConn.close();
                        if(s != null) s.close();
                        if(input != null) input.close();
                    }
                    raw.append(new String(data, 0, len));
                }

                _responseText = raw.toString();

                input.close();
            }

        } catch (IOException ioe) {
            Utils.caughtException(ioe);
        } catch (Exception e) {
            Utils.caughtException(e);
        } finally {
            try {
                if(httpConn != null) httpConn.close();
                if(s != null) s.close();
            } catch (Exception e) {
                Utils.caughtException(e);
            }
            httpConn = null;
        }

        // FIXME remove this
        System.out.println("------------ RESPONSE ------------");
        System.out.println("RESPONSE CODE: " + _responseCode);
        System.out.println("RESPONSE TEXT: " + _responseText);
        System.out.println("------------ RESPONSE ------------");

        // Make things final so we can use them in the inner class
        if ( _stop ) { return; }
        //final String textString = responseMessage;
        final Stoppable ourProcessing = this;
        UiApplication.getUiApplication().invokeLater(new Runnable() {
            public void run() {
                if ( ourProcessing.isStopped() ) { return; }
                //Dialog.alert(textString);
                //callback method called after URL call is completely finished
                _ul.afterURLRequested(_responseText);

            }
        });
    }

    public boolean stop() {
        if ( !_stop ) {
            _stop = true;
            synchronized(_notifyObject) {
                _notifyObject.notify();
            }
        }
        return true;
    }

    public boolean isStopped() {
        return _stop;
    }

}

then call the Utils.getConnection method:

    public static HttpConnection getConnection(String url, StreamConnection s) throws IOException{
        System.out.println("CONNECTING " + url); //FIXME remove this
        HttpConnection httpConn = null;

        //additional coding to retrieve WAP 2.0 UID from device (only if using TRANSPORT_WAP2)
        ServiceBook sb = ServiceBook.getSB();
        ServiceRecord[] records = sb.findRecordsByCid("WPTCP");
        String uid = null;
        for (int i = 0; i < records.length; i++) {

            //FIXME remove all of this
            System.out.println("APN: " + records[i].getAPN());
            System.out.println("CAAddress: " + records[i].getCAAddress());
            System.out.println("CARealm: " + records[i].getCARealm());
            System.out.println("Cid: " + records[i].getCid());
            System.out.println("CidHash: " + records[i].getCidHash());
            System.out.println("CompressionMode: " + records[i].getCompressionMode());
            System.out.println("DataSourceId: " + records[i].getDataSourceId());
            System.out.println("Description: " + records[i].getDescription());
            System.out.println("DisabledState: " + records[i].getDisabledState());
            System.out.println("EncryptionMode: " + records[i].getEncryptionMode());
            System.out.println("HomeAddress: " + records[i].getHomeAddress());
            System.out.println("Id: " + records[i].getId());
            System.out.println("KeyHashForService: " + records[i].getKeyHashForService());
            System.out.println("LastUpdated: " + records[i].getLastUpdated());
            System.out.println("Name: " + records[i].getName());
            System.out.println("NameHash: " + records[i].getNameHash());
            System.out.println("NetworkAddress: " + records[i].getNetworkAddress());
            System.out.println("NetworkType: " + records[i].getNetworkType());
            System.out.println("Source: " + records[i].getSource());
            System.out.println("Type: " + records[i].getType());
            System.out.println("Uid: " + records[i].getUid());
            System.out.println("UidHash: " + records[i].getUidHash());
            System.out.println("UserId: " + records[i].getUserId());
            System.out.println("CAPort: " + records[i].getCAPort());
            System.out.println("ServiceIdentifierSubType: " + records[i].getServiceIdentifierSubType());
            System.out.println("ServiceIdentifierType: " + records[i].getServiceIdentifierType());
            System.out.println("Transport: " + records[i].getTransport());
            //FIXME remove all of this

            // 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;
                    }
                }
            }
        }

        // connect using RIM's connection, using WAP 2         ConnectionFactory connFact = new ConnectionFactory();
        ConnectionDescriptor connDesc = null;
        System.out.println("WAP 2.0 UID = " + uid); //FIXME remove this

        if (uid != null) {
            System.out.println("TRY CONNECTING WAP2"); //FIXME remove this
            // 1. open a WAP 2 connection
            // Connector.open(_url + ";ConnectionUID=" + uid);
            connDesc = connFact.getConnection(url, TransportInfo.TRANSPORT_WAP2, uid);
        }

        if(connDesc != null){
            System.out.println("Transport Type = " + connDesc.getTransportDescriptor().getTransportType()); //FIXME remove this
            httpConn = (HttpConnection) connDesc.getConnection();
        }else{
            System.out.println("TRY CONNECTING STREAM CONN"); //FIXME remove this
            // 2. connect using stream connection
            s = (StreamConnection) Connector.open(url);
            httpConn = (HttpConnection) s;
        }

        // 3. connect using any available HTTP Connection
        if(httpConn == null){
            System.out.println("TRY CONNECTING ANY AVAILABLE TRANSPORT TYPE"); //FIXME remove this
            httpConn = (HttpConnection)Connector.open(url);
        }

        return httpConn;
    }

I tried to use method 3, hoping at least a connection would work (note. I'm not a BB alliance partner, so BIS - B is out of the question):

1. using WAP 2, using the UID from the smart phone

2. with the help of Connector.open (url) (StreamConnection)

3. with the help of (HttpConnection) Connector.open (url)

in the Simulator, the 2nd method works (using the connection of flow)

But in the smartphone, it doesn't, the response returns only the strange characters, for example, is the console log if I execute the Utils.getConnection method and attach the debugger to the smartphone (blackberry 9630 tour):

CONNECTING http://www.XXX.co.id/asdf/bb/sc_merchant.htm
APN: null
CAAddress: null
CARealm: null
Cid: WPTCP
CidHash: -29088066
CompressionMode: 1
DataSourceId: null
Description: WAP2.0 transport service book
DisabledState: false
EncryptionMode: 1
HomeAddress: null
Id: 29
KeyHashForService: -1955927269
LastUpdated: 1285986555595
Name: WAP2 Transport
NameHash: 324338798
NetworkAddress: 0.0.0.0:0
NetworkType: 4
Source: 2
Type: 0
Uid: WAP2 trans
UidHash: -1142978965
UserId: -1
CAPort: 0
ServiceIdentifierSubType: 0
ServiceIdentifierType: 0
Transport: null
WAP 2.0 UID = WAP2 trans
TRY CONNECTING WAP2
JVM:Unsupported Native Method VPN.isVPNSupported[8cb]
VM:NCICv=41
VM:NMACv=13
Adding process=XXX(422) to table
Adding tunnel id=1mode=FG to process=XXX(422)
Transport Type = 3
------------ RESPONSE ------------
RESPONSE CODE: 200
RESPONSE TEXT: j------------ RESPONSE ------------

My question is:

1. I'm doing something wrong? I mean, I tried some connection methods, like using WAP2 by extracting first UIDS or using any transport available, but I still can't get the connection works in the BB smartphone (in the Simulator, it's OK, and I connect to the address is valid)

2 - is there anyway to simulate many different type of transport in the Simulator (BIS-B, WAP1, WAP2, WIFI, etc...)?

Thank you very much

Yusuf

I'm sorry, it seems that I answered my own question again by copy - paste code localytics (http://www.localytics.com/blog/post/how-to-reliably-establish-a-network-connection-on-any-blackberry...)

Tags: BlackBerry Developers

Similar Questions

  • Connection 3G blackBerry Smartphone problem

    Hello! I just got my torch yesterday and I like it so far, but there is a problem: 3G does not work. Not at all. Internet works fine via the wi - fi connection, but if I try to access the internet without my home wi-fi I get the message, "there is an insufficient network coverage for your request. Please try again later. "I have search everywhere on the internet and it seems to be a common problem.

    I tried the battery pull and the phone reset methods. Does not work.

    It does not have 3G in the upper right corner, and I have full bars.

    He has had this problem since I got it, and it's new, so I'm a little upset about this. If I pay for a data plan, I expect to be able to use it.

    Thanks in advance for any help you have to offer.

    Right next to the symbol of the 3 G upper-left, there is a small symbol of BlackBerry?  Who should attend so that you surf on your network connection.

    If it is not present, since your homescreen go in manage connections.  Make sure that your Mobile network is enabled (it will be if you see 3G).  Click on the below Mobile Network Options and make sure that data Services is defined on IT.

    You should now be able to go back and surf in 3G.  I hope that helps you.

  • Network blackBerry Smartphone problem

    When I open the blackberry world it say check connection yournetwork and then try agaim

    Thnak you so the forum is really a big blow to hand all of my problems have been take care of thank you

  • Network blackBerry Smartphone problems

    Hey! I have known problems of network for more than 2 months now... I contact Vodacom service provider and they assured me that their network is working perfectly well.

    I don't know what to do anymore because now I can't access the internet and my Facebook Mobile is just annoying...

    Please help with this problem because I can not continue like this more. Its driving me crazy...

    Please, I beg you!

    Hello Leboh

    Why don't you try to uninstall the Facebook application...

    Open the link in the browser on your blackberry

    http://www.BlackBerry.com/Facebook

    Remember that to access this application, you must have data or BIS plan.

    Kind regards.

    Bravo * don't forget to give to these people who help and advise you about your questions * Can
    Accept as Solution to * comment *.

    @gutijose14

  • Connection USB blackBerry Smartphone problems

    I have a BlackBerry Curve 8330 m running the latest OS updates.

    Recently, my BlackBerry has stopped synchronizing via USB.  My computer is a Windows XP with Desktop Manager v.4.7.  I never had problems with synchronization previously.  Another Member of the family has a BlackBerry Curve as well, and them connects and syncs perfectly.  Thus, this addresses the problems with the USB cable and the computer itself.

    When my BlackBerry is connected, the indicator is on, but my XP does not recognize that have plugged in at all.  In the Windows Device Manager, it is said that there is no active USB connection.

    Suggestions, please?

    I tried all the stuff into the Knowledge Base of BlackBerry.  I also tried syncing my BlackBerry to the computer of a friend who use Desktop Manager and gave the same frustrating results.

    After several hours of anguish, I decided to do a clean wipe of my phone... success!  Obviously, a file has been corrupted that was vital to the process of USB connection.   Fortunately, I made a backup last week, so I do not lose too much data.

  • About connection network blackBerry Smartphones

    Hello everyone!

    At first, I must say that I am a newbie with the BlackBerry.

    I use T-Mobile as a career.

    The maximum speed I get from the repartir0 of the career is 7.2/1,4 Mbps... However, my question is this:

    If I am at home with my device BB and at home I have the WiFi router and my BB is connected, if I try to open certain pages or some do sort of request to the Internet, the BB will use the 3G connection or my WiFi?

    I tried to check the system where I can order the connections (1. WiFi - or tier 2. 3 tc g.)

    It is perhaps a silly question, but please help me!

    Best regards

    Dean

    Hiya!

    and the answer is...

    If you connect wirelessly, your device will use it instead of your 3 G/EDGE current connection. When not in the scope of the WiFi, it will be automatically 3 G/EDGE.

  • Cisco AnyConnect VPN Client (connection attempt failed because the network or pc problem cisco)

    Hi all

    I am trying to connect to my Cisco AnyConnect VPN Client but everytime I try, I get an error (connection attempt failed because the network or pc problem cisco)

    Can anyone help me please with this.

    Thank you

    Zia

    What is the local firewall on your computer?

  • Problem of not seeing list drop-down connection to the wireless network when checking connections network - pc windows 7.

    Problem of not seeing list drop-down connection to the wireless network when checking connections network - pc windows 7.

    I just installed a Belkin modem-router - which went well. Can I connect WiFi gadgets etc. I can also connect to the internet via a network cable to my pc. I also installed a belkin usb wireless adapter and in Device Manager, says it is enabled and works.

    My problem is, I have no way of choice get a WiFi PC to display in the list (from the notification area) and cannot get the pc to give me options to create a wi - fi connection. The more I get to try to do that is "unexpected error"!

    If someone could help on this - I would be very grateful

    Good news - update of my ongoing saga with this Belkin modem/router.

    Got the pc to see wi - fi now. It turned out to be the Zone Alarm! As the router has a firewall, I uninstalled Zone Alarm completely. Also, I went into the properties of belkin usb and checked it was the most recent drivers, it does not so I installed them.

    So far so good

    Thanks for the help

    TREV Smith

  • Connect Mobile HP network adapter driver problem

    Mobile connect stopped functioning. Device Manager indicates that HP Mobile COnnect Network Driver has no driver installed.

    The States of information

    USB\VID_03F0 & PID_581D & REV_0228 & MI_03

    USB\VID_03F0 & PID_581D & MI_03

    Where I find the driver?

    You are the very welcome.

    This should be the driver that you need for this device:

    http://h20566.www2.hp.com/portal/site/hpsc/template.PAGE/public/psi/swdDetails/?sp4ts.oid=5405387&spf_p.tpst=swdMain&spf_p.prp_swdMain=wsrp-navigationalState%3Didx%253D%257CswItem%253Dob_133017_1%257CswEnvOID%253D4060%257CitemLocale%253D%257CswLang%253D%257Cmode%253D%257Caction%253DdriverDocument&javax.portlet.begCacheTok=com.vignette.cachetoken&javax.portlet.endCacheTok=com.vignette.cachetoken

  • Network of Smartphones blackBerry or software problem...?

    Have had my Storm 2 for 4 months now without any problem, but after that I came back from vacation the other day (the phone remained throughout my trip turned off) I had a problem with voice calls.

    Location:

    Sometimes, during a telephone conversation, the two parties may try to talk at the same time, i.e. you talk and someone tries to interrupt or vice versa...

    Question:

    Since I just got back from vacation for a reason any now my phone makes a weird sound when this event occurs, like a network or signal problem (audio gets garbled). Has never done this before (I would have noticed it, I get about this stuff) so I went to the Verizon Corp store. They did their magic * 29, 28 or whether it's and said that will fix it. Well there not... If they swapped the phone that was working fine until I did the software upgrade a few days later. Now, I have the same problem again! I use this for my company and it's driving me crazy!

    I am alone on this issue, or so everyone knows the same thing? Just curious, before returning to the store and complain.

    Thank you for any input!

    Do not know if someone posted this in another thread, but given that it pertained to my original question, I wanted to keep him here.

    I realized with my newly improved DM 6.0.0.40, it gives you the opportunity to return to your OS devices.

    IN the new DM software, you click Device > update my device > see other Versions > select the operating system you want to install. (Mine has shown the last three) I selectionne.607 and follow the steps. Fact!

    Now I'm back a.607 and no voice problems.

  • Connection network satellite L655-121 always shows 'disconnected '.

    Model: Toshiba Satellite L655-121
    OS: Windows 7 Home Premium
    NETWORK card: Atheros 8152 - 1.0.0.36 driver version (also tried 1.0.0.26)

    connection network always shows 'disconnected '.

    I tried the following:
    -straight cable connection from the laptop to the router - no link
    -crossover PC-to-phone cable connection = no connection
    -used work cable from the printer to the router and the laptop to router - no link
    -changed (tested) cable and router port - no link

    also a linux distribution installed with shows the installed NIC but his are not all RX or TX packets
    diagnosis with toshiba used cable connected - message was "cable can be damaged or not connected.

    all other tests I should try/run before going to the Service Center Toshiba for repairs, and how long they can hold my laptop for repairs - the whole motherboard must be replaced?

    Are you using 64 bit OS originally that you got with your laptop?
    Have you noticed this problem from the beginning?

    Card LAN listed and activated correctly in Device Manager?

    When you connect the LAN cable is green LED on?

  • Windows Vista + Netgear - Netgear says that I'm connected network list said I'm limited, the computer shows that I am not at all. Computer is right.

    I have fixed everything at the time of my desktop computer starts up to a screen black with no explorer.exe running (the explorer.exe running only showed a folder at a time, until I restarted it.) and now I have a connection problem.

    My netgear router has a connection with my computer, it shows green in the taskbar. However, my actual connection to the internet is not as lucky as the connection with the router.

    I see the networks that I am able to connect to, but as soon as I did, I said that I am not currently connected to any network. If I go to "Connect to a network" I see clearly that I'm "connected with limited access" to Snet-G, which is one of the networks available to connect.

    In my options of netgear, I am also connected to Snet-G, and it shows that it is actually connected.

    My problem is the fact that I can "ipconfig" and I find none of my information, and when I try to ipconfig/all, it gives me an error something while not connected, so it says that I'm connected and does not, at the same time. My local internet does not work (can not navigate to 192.168.1.1 and others), and of course for this reason, my global internet does not work.

    I need a fix for this, because I just put a ton of subscriptions for this month, which are already paid, and if I can't use this month is a good slice of $50 trash just because I fixed something.

    Thanks, that's a well advanced topic.

    I tried the following:
    System Restore (6 days back, the problem started 2 days ago)
    Restarting the computer
    Unplug modem (30 seconds)
    Restarting the router/Reset
    Connection to the Snet-N instead of the Snet-G

    Things to take note, if you do not already consider: I can't connect to my router config (192.168.1.1), my computer says I am connected locally, but not in the world.
    I have some information about the modem if necessary.
    -I have restored my computer 6 days ago, but only changed my problem with explorer.exe back. Internet broke again-. -.

    Hello

    Method 1:

    I suggest you to follow the links and check out them.

    Windows wireless and wired network connection problems

    http://Windows.Microsoft.com/en-us/Windows/help/wired-and-wireless-network-connection-problems-in-Windows

    Network connection problems

    http://Windows.Microsoft.com/en-us/Windows-Vista/troubleshoot-network-connection-problems

    The problems of Internet connection

    http://Windows.Microsoft.com/en-us/Windows-Vista/troubleshoot-Internet-connection-problems

    Method 2:

    I also suggest that you see the link and search for connected with limited access

    Message when a device on a Windows Vista-based computer uses a network bridge to access the network: "connected with limited access".

    http://support.Microsoft.com/kb/930517

  • Pavilion 15-ab063tx: 15-ab063tx Pavilion network controller driver problem

    Hello

    I just bought a new 15-ab063tx Pavilion and after format, I have a wireless network connection problem. For the network local network it works well but I can't find the wireless network adapter. On the device he received the error this network controller driver problem. Can someone help me.

    Realtek Wireless:

    http://h20566.www2.HP.com/hpsc/SWD/public/detail?sp4ts.Oid=6943827&swItemId=ob_149229_1&swEnvOid=4158

    Bluetooth:

    http://h20566.www2.HP.com/hpsc/SWD/public/detail?sp4ts.Oid=6943827&swItemId=ob_147638_1&swEnvOid=4158

  • Why ASA in transparent mode require same subnet ip to that of the connected network

    ASA transparent mode, why it is necessary to keep the management ip on the same subnet to the connected network?

    What happens if I keep managing ip in a different subnet as the network connected?

    If I only did traffic to move through to the asa and why?

    thanxs.

    Hello Vijay,

    As you say you can use another, that is right, but the thing is that the IP address of management is not only used to draw management.

    Who was you are missing the point.

    That the IP address assigned to the ASA as a whole also will be used for ARP requests when the ASA does not know where the destination hosts lies and is not on the same subnet as the ASA.

    It will serve as a source for packages destined to a syslog server, server AAA, Netflow server, SNMP server, and any package that ASA will have to create so in that spirit the routing of the network will have to be modified to work with that.

    If you come to realize that the routing of the network works with a different management on the transparent address IP address then you can do it. I can assure you that I have seen this scenario before working with no problems at all BUD.

    Just to remember to Note all useful posts like this

    Looking for a Networking Assistance?
    Contact me directly to [email protected] / * /

    I will fix your problem as soon as POSSIBLE.

    See you soon,.

    Julio Segura Carvajal
    http://laguiadelnetworking.com

  • Check if a virtual machine has connected network and connect if it isn't?

    Thus, creating a big deployment VM automation workflow, I need a way to check and make sure that the deployed virtual computer has its connected network. However, I can't seem to find a way to generate scripts which correctly. Any ideas?

    Hello

    There are different strategies. Look at the 'vim3waitDNSNameInTools' action, it waits until the virtual machine arrives with a given host name. Which ensures that this customization is done completely.

    Alternatively you can ping the virtual computer by using the System.isHostReachable () method, find an example here: Ping on the workflow server

    (I remember there were some problems with this method in previous versions, be sure to properly test ;-))

    Another strategy might be to use the operations of comments and call a ping of in the guest operating system (with which you shall vro network connection to the virtual machine itself, you can for example leave the guest operating system ping the address of the gateway or so)

    Kind regards

    Joerg

Maybe you are looking for

  • BIOS update failed with the Satellite A210-17Z

    I was asked by Tempro to update the BIOS of my laptop Satellite A210-17Z.I agreed but the laptop turns off before completing the update of the BIOS. As a result, I can no longer boot my computer. Looking for a solution on the internet, I have read th

  • Satellite C660D froze and won't start - Windows could not start

    OK, enough of the more dense person you will ever likely to meet when it comes to things like that. but will try my best to explain. There are a few days that my laptop has frozen on me on me having to turn it off and start it again by the power butt

  • Error codes 78(f)), 80070308 and 8007000 D (failure of the installation of 12 updates in Windows 7 HP64)

    No idea what to do now. I tried to select only some and even unstalling all updates and walk away with the prize, but nothing helped. I ave nothing else running while I update - except Microsoft Security Essentials, but I even tried to disable the pr

  • PCIe Bus error warning

    Hello need help with this error... You can find the error image to attach file... it's only happen when chart pantented is connected, it's all new alienware leptop 17 r3...

  • Cannot install the USB mouse driver

    I recently bought a simple mouse, wired Plug-and-Play, but when I connected it to my computer, nothing happened before or after that the computer said that it had installed the drivers for it. Thinking that there was something wrong with the mouse, I