BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 06-23-2008, 01:54 AM   #1
arunk
Talking BlackBerry Encyclopedia
 
arunk's Avatar
 
Join Date: Mar 2008
Model: 8310
PIN: N/A
Carrier: Airtel
Posts: 229
Question How can I configure the settings from a URL?

Please Login to Remove!

In my Application I have an option to configure some settings from an XML file.

I want to do the same from a URL...

ie an XML file will be there on our website and by entering the url I should be able to get the contents of the XML file....
Offline  
Old 06-23-2008, 02:49 AM   #2
simon.hain
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Default

read the file using a httpconnection and pass it over to your xml parser, not much difference compared to reading it from a file.
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 06-23-2008, 05:33 AM   #3
arunk
Talking BlackBerry Encyclopedia
 
arunk's Avatar
 
Join Date: Mar 2008
Model: 8310
PIN: N/A
Carrier: Airtel
Posts: 229
Smile

Thanks !!!
Offline  
Old 07-21-2008, 06:11 AM   #4
arunk
Talking BlackBerry Encyclopedia
 
arunk's Avatar
 
Join Date: Mar 2008
Model: 8310
PIN: N/A
Carrier: Airtel
Posts: 229
Question

Can anyone help me with a code sample which can read a file(xml file) content.

I have to read an xml file and get the contents a s a string...
Offline  
Old 07-21-2008, 06:32 AM   #5
Jayaseelan
Thumbs Must Hurt
 
Join Date: Jun 2008
Location: Chennai
Model: 8130
PIN: N/A
Carrier: AIRTEL
Posts: 51
Default

hi,

StringBuffer str = "";

Input Streram is = c.openInputStream();
int ch;
while ((ch = is.read()) != -1)
{
str.append((char)ch);
}
String stringE = new String(str);

After getting the xml file as Inputstream using Http Connection use this code..
__________________
Jayaseelan.V
Mobile Application Developer
INDIA.
Offline  
Old 07-21-2008, 07:40 AM   #6
arunk
Talking BlackBerry Encyclopedia
 
arunk's Avatar
 
Join Date: Mar 2008
Model: 8310
PIN: N/A
Carrier: Airtel
Posts: 229
Default

I did a mistake in between and its fixed.

Thanks..
Offline  
Old 08-04-2008, 01:52 AM   #7
arunk
Talking BlackBerry Encyclopedia
 
arunk's Avatar
 
Join Date: Mar 2008
Model: 8310
PIN: N/A
Carrier: Airtel
Posts: 229
Question

I am able to read the contents and make the settings in Simulator..
But its not working in device...

I am getting exception
"blocking operation not permitted on event dispatch thread".

from the previous posts I came to know that http READ should be in different thread..

When the user enter the url, I am reading the file , then parse it and save the settings.. How can I do it without the above mentioned an excption..
Offline  
Old 08-04-2008, 04:42 AM   #8
simon.hain
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Default

seems that you have your connection within your UI classes. networking should run in an own thread. give the thread a callback (your application as an interface) with a method to call if the data is received.
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 08-04-2008, 07:09 AM   #9
arunk
Talking BlackBerry Encyclopedia
 
arunk's Avatar
 
Join Date: Mar 2008
Model: 8310
PIN: N/A
Carrier: Airtel
Posts: 229
Question

I tried it and I am getting an IOexception. Invalid tunnel name..

is there any difference in accessing the data through, Wi - fi and gprs?
Offline  
Old 08-05-2008, 12:25 AM   #10
arunk
Talking BlackBerry Encyclopedia
 
arunk's Avatar
 
Join Date: Mar 2008
Model: 8310
PIN: N/A
Carrier: Airtel
Posts: 229
Question

My code works fine in simulator, but in device its not working...

I am able to access internet through the browser in blackberry...

is there any specific settings or options to do it...
Offline  
Old 08-05-2008, 01:55 AM   #11
Jayaseelan
Thumbs Must Hurt
 
Join Date: Jun 2008
Location: Chennai
Model: 8130
PIN: N/A
Carrier: AIRTEL
Posts: 51
Default

Hi Arun,

Can i have the link for your xml data?

Can you please mention where that exception occurs exactly?
__________________
Jayaseelan.V
Mobile Application Developer
INDIA.
Offline  
Old 08-05-2008, 02:48 AM   #12
arunk
Talking BlackBerry Encyclopedia
 
arunk's Avatar
 
Join Date: Mar 2008
Model: 8310
PIN: N/A
Carrier: Airtel
Posts: 229
Default

Exception occurs when the connection is set..

c = (HttpConnection)Connector.open(url);
Offline  
Old 08-05-2008, 03:18 AM   #13
Jayaseelan
Thumbs Must Hurt
 
Join Date: Jun 2008
Location: Chennai
Model: 8130
PIN: N/A
Carrier: AIRTEL
Posts: 51
Default

Hi Arun,

Check clearly, Have you use separate thread for HttpConnection?

Simulator there is no problem..But in real device you should use separate thread..
__________________
Jayaseelan.V
Mobile Application Developer
INDIA.
Offline  
Old 08-05-2008, 04:15 AM   #14
arunk
Talking BlackBerry Encyclopedia
 
arunk's Avatar
 
Join Date: Mar 2008
Model: 8310
PIN: N/A
Carrier: Airtel
Posts: 229
Default

This is the code I am using... is there any mistake in this ?

I am getting an open tunnel failure while executing the code:

c = (HttpConnection)Connector.open(url);


Code:

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;


import javax.microedition.io.HttpConnection;
import java.util.Vector;
import java.util.Enumeration;

import javax.microedition.io.Connector;
import net.rim.device.api.io.file.ExtendedFileConnection;


public class ReadHttpFile extends Thread{
         HttpConnection c = null;
         InputStream is = null;
         String XMLdata = "";
         int rc;
         public boolean isInvalidFile=false;
         String url;
        
     ReadHttpFile(String URL) {          
          url = URL;
     }
                
        public void run() {
            try{
                ReadData(url);
            }catch(IOException ie){
            }
        }
            public void ReadData(String url) throws IOException{
                try {
      
                        c = (HttpConnection)Connector.open(url);
      
            
                        // Getting the response code will open the connection,
                        // send the request, and read the HTTP response headers.
                        // The headers are stored until requested.
                        if(c!=null){
      
                            rc = c.getResponseCode();
                            if (rc != HttpConnection.HTTP_OK) {      
      
                                isInvalidFile=true;              
                            }
      
                            is = c.openInputStream();                          
                            StringBuffer sb = new StringBuffer();
                            int ch;
                            while ((ch = is.read()) != -1) {
                                sb.append((char) ch);
                            }
                            XMLdata = sb.toString();                            

                            System.out.println("XML "+ XMLdata); 
                        }
            
                    }catch(IOException ioe){
                        System.out.println("Exception : "+ ioe.toString());                   
                        isInvalidFile=true;              
                        
                    }catch(Exception e){
                        System.out.println("Exception : "+ e.toString());                   
                        isInvalidFile=true;              
                        
                    } finally {
                        if (is != null)
                            is.close();
                        if (c != null)
                            c.close();
                    }
                   
                 
        }

}

Last edited by arunk; 08-05-2008 at 04:37 AM..
Offline  
Old 08-06-2008, 01:53 AM   #15
arunk
Talking BlackBerry Encyclopedia
 
arunk's Avatar
 
Join Date: Mar 2008
Model: 8310
PIN: N/A
Carrier: Airtel
Posts: 229
Question

I just want to read the contents..
application is able to do it in simulator but not in device...

somebody please help to identify the problem...
Offline  
Old 08-06-2008, 09:22 AM   #16
bemshaswing
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Default

What exactly is the error you're receiving on c = (HttpConnection)Connector.open(url);
Offline  
Old 08-07-2008, 12:00 AM   #17
arunk
Talking BlackBerry Encyclopedia
 
arunk's Avatar
 
Join Date: Mar 2008
Model: 8310
PIN: N/A
Carrier: Airtel
Posts: 229
Default

Invalid tunnel name....
Offline  
Old 08-14-2008, 02:43 AM   #18
arunk
Talking BlackBerry Encyclopedia
 
arunk's Avatar
 
Join Date: Mar 2008
Model: 8310
PIN: N/A
Carrier: Airtel
Posts: 229
Question

yaa I am able to do this...


Its working in India with aritel' gprs...

But the same application is not working in Germany with T-mobile...

What I did is I am getting the service book entry with CID as WAP ... then I will get 2 records with names "wap transport" and "MMS" so I will check for the name "wap transport" and both matches I will use the apn and ip of that record...

Anyone uses gprs in germany, please tell me how these entries differ in your devices or corresponding entries in your devices...


Thanks
Offline  
Old 08-14-2008, 03:28 AM   #19
simon.hain
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Default

here are the german APNs (page in german, but the data should be understandable)
another page that lists a lot of APNs is pinstack
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 08-14-2008, 03:51 AM   #20
arunk
Talking BlackBerry Encyclopedia
 
arunk's Avatar
 
Join Date: Mar 2008
Model: 8310
PIN: N/A
Carrier: Airtel
Posts: 229
Question

Actually I want to know, when gprs service is enabled, the entry which is created in service book corresponding to that on the device and the details..

if you have a gprs connection, can you please check in your device service book and give me the info....?


Another thing i want to ask is how we can activate BES.. whats the procedure?
and will this let you access the internet? (seen something in device like exterprise activation which needs email and password.. how i can get it?)
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


A54MA55B and BC186A413G52 frequency converters A500/F540 series 55KW drive board picture

A54MA55B and BC186A413G52 frequency converters A500/F540 series 55KW drive board

$350.00



Dentistry Replacement NSK TiMAX NL95M/ A500/ A500L/ AK500L/ AS500L /AW500L NEW picture

Dentistry Replacement NSK TiMAX NL95M/ A500/ A500L/ AK500L/ AS500L /AW500L NEW

$79.95



New Greaseweazle V4.1 USB Floppy Adapter Flux Reader Writer Amiga PC Case 1598 picture

New Greaseweazle V4.1 USB Floppy Adapter Flux Reader Writer Amiga PC Case 1598

$36.05



1PC USED A54MA55B BC186A413G52 Mitsubishi A500/F540 Series 55KW Drive Board #CZ picture

1PC USED A54MA55B BC186A413G52 Mitsubishi A500/F540 Series 55KW Drive Board #CZ

$317.00



NEW OPTICAL LASER PICKUP HEAD for AMIGA CD 32 SYSTEM CONSOLE picture

NEW OPTICAL LASER PICKUP HEAD for AMIGA CD 32 SYSTEM CONSOLE

$31.68



MITSUBISHI A500 / FR-A540-5.5K-NA INVERTER 3PH  picture

MITSUBISHI A500 / FR-A540-5.5K-NA INVERTER 3PH

$108.00







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