开发者

Android Remote XML File access

开发者 https://www.devze.com 2023-03-19 21:00 出处:网络
In my android application I need to get an input stream from a remote xml file(In a remote server) that has extension gz. Eg student.gz.

In my android application I need to get an input stream from a remote xml file(In a remote server) that has extension gz. Eg student.gz.

I just tried to connect but give an exception "Exception message: Not trustered server certificate". Its a https connection and when we normally log in to server, we have to give username and password.

So how in code we can access this XML files(xmlfile.gz) and get the content in this files. I tried following code which gives me exception

URL url = new URL("https://REMOTE_SERVER_LOCATION/PATH/s开发者_运维问答tudent.gz");
HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection();
        try 
        {
            InputStream in = new BufferedInputStream(urlConnection.getInputStream());
        }
        finally  
        { 
            urlConnection.disconnect(); 
        }


see http://groups.google.com/group/android-developers/browse_thread/thread/1ac2b851e07269ba and http://blog.crazybob.org/2010/02/android-trusting-ssl-certificates.html they will help you

0

精彩评论

暂无评论...
验证码 换一张
取 消