I am trying to make a simple app. I have a method for returning an InputStream
and then I will bind this stream to an ImageView. But it doesn't work as always. There is no exception. What am I doing wrong. How can I make this code run?
String[] names;
Bitmap bmp;
ImageView img;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AssetManager am=getAssets();
img = (ImageView)findViewById(R.id.imageView1);
try {
names=am.list("myfiles");
InputStream is=bitmapStream(names[1]);
bmp =BitmapFactory.decodeStream(is);
img.setImageBitmap(bmp);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public InputStream bitmapStream(String name) throws FileNotFoundException {
InputStream is = null;
is = openFileInput(name);
return is;
}