put() in ResponseCache invoked with a wrong URI?

by Guitou » Mon, 03 Aug 2009 15:27:29 GMT


Sponsored Links
 Hi,
I extended ResponseCache as follow :

public class DataLoader extends ResponseCache {

        @Override
        public CacheResponse get(URI uri, String arg1,
                        Map<String, List<String>> arg2) throws IOException {
                // TODO Auto-generated method stub
                Log.i("DataLoader", "Get()" + uri);
                return null;
        }

        @Override
        public CacheRequest put(URI uri, URLConnection conn) throws
IOException {
                // TODO Auto-generated method stub
                Log.i("DataLoader", "Put()" + uri);
                return null;
        }
}

I use this code to retrieve datas :

                ResponseCache.setDefault(new DataLoader());
                URI uri;
                HttpURLConnection conn;
                try {
                        uri = new 
URI(" http://www.google.com/intl/en_ALL/images/logo.gif" ;);
                        conn = (HttpURLConnection)uri.toURL().openConnection();
                        InputStream inputStream;
                        inputStream = conn.getInputStream();
                        inputStream.close();
                } catch (MalformedURLException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                } catch (IOException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                } catch (URISyntaxException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                }

But when I look to my logs, the URI sent to the get() method is good
( http://www.google.com/intl/en_ALL/images/logo.gif ) but in the put()
it does not give me the same URI but only  http://www.google.com 
Is that normal?
How to get the full url in put() ?
Thanks for your help!
--~--~---------~--~----~------------~-------~--~----~



put() in ResponseCache invoked with a wrong URI?

by Matt Kanninen » Sat, 19 Sep 2009 08:45:03 GMT


 I am seeing the same thing.



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


put() in ResponseCache invoked with a wrong URI?

by Matt Kanninen » Sat, 19 Sep 2009 11:13:24 GMT


 To answer the question of how to get the full url, my work around was
to use conn.getURL() instead of the passed URI.  So it would be:

        public CacheRequest put(URI uri, URLConnection conn) throws
IOException {
                // TODO Auto-generated method stub
                Log.i("DataLoader", "Put() " + conn.getURL);
                return null;
        }




--~--~---------~--~----~------------~-------~--~----~



put() in ResponseCache invoked with a wrong URI?

by Guitou » Wed, 30 Sep 2009 02:49:28 GMT


 I will give it a try! Thanks Matt





--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Getting contact name from phone number in 1.5/1.6/2.0

Hi -- the semi-standard way of getting a contact name from a phone
number is to use Contacts.Phones.CONTENT_FILTER_URL and append the
phone number, as in the following sample code.  This works fine on
Android 1.6, but not on 2.0 -- is there a way to perform this function
that works in all versions of the Android API?


private String getContactNameFromNumber(String number) {
                // define the columns I want the query to return
                String[] projection = new String[] {
                                Contacts.Phones.DISPLAY_NAME,
                                Contacts.Phones.NUMBER };

                // encode the phone number and build the filter URI
                Uri contactUri = Uri.withAppendedPath
(Contacts.Phones.CONTENT_FILTER_URL, Uri.encode(number));

                // query time
                Cursor c = getContentResolver().query(contactUri, projection, 
null,
                                null, null);

                // if the query returns 1 or more results
                // return the first result
                if (c.moveToFirst()) {
                        String name = c.getString(c
                                        
.getColumnIndex(Contacts.Phones.DISPLAY_NAME));
                        return name;
                }

                // return the original number if no match was found
                return number;
        }

-- 

2. ListView not responding to Click or KeyPress

This is unnecessary. This problem will occur if your list item
contains focusable children (like buttons, edittexts, etc.)





> 

3. Mau bagi-bagi game UNO menjelang libur panjang

4. how to capture key events with a window-less activity

5. postBuffer and memcpy

6. How can I use org.apache.harmony.luni.platform.OSNewtorkSystem in Android SDK ?

7. Using multiple layouts for different screens.