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
New Developer
Posts: 66
Registered: ‎11-23-2009
My Device: Not Specified

having my app use wifi

 

                String murl = "homepage.mac.com/brentris/my_song.mp3;deviceside=true";

                HttpConnection conn = (HttpConnection) Connector.open(murl, Connector.READ_WRITE);

                conn.setRequestMethod(HttpConnection.GET);

                if(conn.getResponseCode() != HttpConnection.HTTP_OK)

                {

                    return false;

                }

                InputStream is = conn.openInputStream();

                SharedInputStream readAhead = SharedInputStream.getSharedInputStream(is);

                _player = Manager.createPlayer(readAhead, "audio/mpeg");

                _player.realize();

_player.prefetch();

_player.start();

 

 

This is my radio streaming app. It is loading an MP3 stream (using my_song.mp3 here as an example). I tried running this on my device with all radios on, and it works great, but if I try to run with only wifi on, it won't load. Why not? It works if I append ;interface=wifi at the end of the URL, but I want it to try wifi first, and if wifi won't work I want it to try EDGE/3G...

 

What's the most painless way to do this?

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: having my app use wifi

To determine if wi-fi is supported on a device use RadioInfo.areWAFsSupported().

 

To determine if wi-fi is currently available on a device use CoverageInfo.isCoverageSufficient().  

Contributor
Posts: 23
Registered: ‎04-29-2010
My Device: Storm 9500
My Carrier: Vodafone

Re: having my app use wifi

Hi brent!

 

I tried using your code for a part of developing an online radio 
and the simulator is working properly. However've installed 
application on a BlackBerry Curve 8900 and does not work: S. 

What could be the problem?

 

The code is :

 

 

String murl = "http://94.23.243.20:8128;deviceside=true";
                HttpConnection conn = (HttpConnection) Connector.open(murl, Connector.READ_WRITE);
                conn.setRequestMethod(HttpConnection.GET);
                if(conn.getResponseCode() != HttpConnection.HTTP_OK)
                {
                	System.out.println("No conecta!");
                }
                InputStream is = conn.openInputStream();
                SharedInputStream readAhead = SharedInputStream.getSharedInputStream(is);
                player = Manager.createPlayer(readAhead, "audio/mpeg");
                player.realize();
                player.prefetch();
                player.start();
    			
    		}catch(Exception e){
    			System.out.println("No hace el stream!");
    		}

 Thanks!

 

 

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

Re: having my app use wifi

Please review this Thread:

http://supportforums.blackberry.com/t5/Java-Development/Connecting-your-BlackBerry-http-and-socket-c...

noting especially, the Required Reading.  You need to review carefully what works on the Simulator and what actually happens on the real device.