This is a pretty basic thing but I couldn't get it to work in a more
complex routine so I tried to reduce it to the simplest possible thing
and it still won't work and it is driving me up a wall!

I am trying to set an image on an ImageView using the function
setImageURI(), the program compiles however the ImageView is blank and
never gets set. And in the logcat it gives the error:

11-27 22:23:51.405: INFO/System.out(18614): resolveUri failed on bad
bitmap uri: file:///sdcard/icon.png

However I know this is a good URI because I can get the gallery to
show the image using an intent with the same URI.

What am I missing??!


*** images.java ***

public class images extends Activity {

     private ImageView iv;

    @Override
    public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);

          // make file reference
          File file = new File("/sdcard/icon.png");
          Log.d("here", "Does this exist? " + String.valueOf
(file.exists()));

          // create uri for file
          Uri uri = Uri.fromFile(file);

          //reference the imageview
          iv = (ImageView) findViewById(R.id.photo);
          iv.setImageURI(uri);

          Log.d("here",uri.getPath());

          // call an android image viewer
//        Intent intent = new Intent
(android.content.Intent.ACTION_VIEW);
//        intent.setDataAndType(uri, "image/png");
//        startActivity(intent);

    }
}


**** main.xml - layout ****

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
    <ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/photo"
    />
</LinearLayout>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to