downloading an image

by Will » Mon, 02 Mar 2009 11:25:24 GMT


Sponsored Links
 How do I download an image? Is there an easy way, given a URL, to
download a .jpg into res/drawable?
I'm trying to download an image and then display it. I'm using a class
that I've tested (but not on android) that downloads an image to a
specified path. When I run it in android, the image doesn't download.
Any help would be SUPER.
Thanks.

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



Other Threads

1. list view button error

Hi guys im trying to put a button on each row of a list but i get null
pointer exception, i'll show the java files below. The list view is in
a seperate xml file to the button because button is inside a relative
layout. Can anyone help?.

This class gets data from a database and puts it in array and displays
in a list view which works fine until i try to put a button in each
row.
Java:

package project.Maps;
public class SatMain extends Activity {
    /** Called when the activity is first created. */
     ArrayList<String> results = new ArrayList<String>();
     @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        dbAdapter db = new dbAdapter(this);

          ;



        //---get all titles---
        db.open();
          db.InsertData();

        Cursor c =  db.getSat1();

        if (c.moveToFirst())
        {
            do {
                 String pub =  c.getString(c.getColumnIndex
(db.KEY_Artist));
                 String pub1 =  c.getString(c.getColumnIndex
(db.KEY_Time));



              results.add(pub + pub1 );
            } while (c.moveToNext());
        }
        db.close();

        ListView listProducts;
        List<String> results = new ArrayList<String>();
        Context cont = null;
          customArray ca = new customArray(cont, R.layout.button,
results);
        listProducts = (ListView)findViewById(R.id.list123);
        listProducts.setAdapter(ca);
        ca.notifyDataSetChanged();
    }}



Code for my custom adapter.

Java:

package project.Maps;
import java.util.List;
public class customArray extends ArrayAdapter<String> {
     int resource;

     public customArray(Context cont, int _resource, List<String>
results) {
          super (cont, _resource, results);
          resource = _resource;
     }

     @Override
     public View getView(int position, View convertView, ViewGroup
parent) {
          RelativeLayout rl;

       //   String prod = getItem(position);
          if (convertView == null) {
               rl = new RelativeLayout(getContext());
               LayoutInflater vi = (LayoutInflater)getContext
().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
               vi.inflate(resource, rl, true);
          } else {
               rl = (RelativeLayout)convertView;
          }


          return rl;
     }
}

--

2. Problem finding a contact when ID is known

I am having a problem viewing a contact in my app when I know the ID
(because we just queried and stored it).

I see some comments that a "LOOKUP_URI" is required but I don't know
how to use it and no matter what, I get "The contact does not exist"
even though I know with 100% certainty that it does.

Can someone explain based on the following code snippet:

String name = ContactNameList.get(position);
String strID = ContactIDList.get(position);
Uri contactUri = ContactsContract.Contacts.getLookupUri(Long.parseLong
(strID), "name='"+name + "'");
Intent intent = new Intent(Intent.ACTION_VIEW,contactUri);
                                startActivity(intent);

I am finding that ID = 676 for example and that is getting parsed
correctly and also that name='Joe Smith' does not throw an error but
my activity does not open the contact - I only get the message "The
contact does not exist" in a toast.

Please help!  Thanks very much!

-- 

3. How can Camera API support two camera device?

4. How can I signal an AppWidgetProvider from a service running in another process

5. showing XML data in TAB in ANDROID

6. Problem sending a file via Bluetooth

7. size limit of shared preferences