Looks like I need android.content.res.AssetManager and
android.content.res.Resources instances to make this work in full.
>From what I see in sources, this is not available :(

On Nov 14, 8:43 am, port443 <[email protected]> wrote:
> I tried (I'm just playing with a black box here):
>
>                         Class<?> pc = caller.getClass();
>                         String imgName;
>                         InputStream is;
>
>                         imgName = "drawable/" + buttonImgName;
>                         is = pc.getResourceAsStream(imgName);
>
>                         imgName = "/drawable/" + buttonImgName;
>                         is = pc.getResourceAsStream(imgName);
>
>                         imgName = "res/drawable/" + buttonImgName;
>                         is = pc.getResourceAsStream(imgName);
>
>                         imgName = "/res/drawable/" + buttonImgName;
>                         is = pc.getResourceAsStream(imgName);
>
>                         imgName = "drawable/" + buttonImgName + ".png";
>                         is = pc.getResourceAsStream(imgName);
>
>                         imgName = "/drawable/" + buttonImgName + ".png";
>                         is = pc.getResourceAsStream(imgName);
>
>                         imgName = "res/drawable/" + buttonImgName + ".png";
>                         is = pc.getResourceAsStream(imgName);
>
>                         imgName = "/res/drawable/" + buttonImgName + ".png";
>                         is = pc.getResourceAsStream(imgName);
>
>                         imgName = "drawable-mdpi/" + buttonImgName;
>                         is = pc.getResourceAsStream(imgName);
>
>                         imgName = "/drawable-mdpi/" + buttonImgName;
>                         is = pc.getResourceAsStream(imgName);
>
>                         imgName = "res/drawable-mdpi/" + buttonImgName;
>                         is = pc.getResourceAsStream(imgName);
>
>                         imgName = "/res/drawable-mdpi/" + buttonImgName;
>                         is = pc.getResourceAsStream(imgName);
>
>                         imgName = "/res/drawable-mdpi/" + buttonImgName + 
> ".png";
>                         is = pc.getResourceAsStream(imgName);
>
> Last case is the only one where I receive non-null stream :(
> What am I doing wrong?
>
> Andrew.
>
> On Nov 11, 3:09 pm, Dianne Hackborn <[email protected]> wrote:
>
>
>
>
>
>
>
> > This uses the same resource matching as all other resources.  The only
> > difference is that it can't of course scale your stream to adjust for
> > differences in density.
>
> > On Fri, Nov 11, 2011 at 7:35 AM, port443 <[email protected]> wrote:
> > > Hi, I'm trying to use Class.getResourceAsStream for an APK which I
> > > loaded myself via DexClassLoader.
>
> > > I can load an image if I specify it in full (e.g. "/res/drawable-mdpi/
> > > myimage.png"); this works.
>
> > > I wonder if there's a way to employ resource matching function of
> > > Android
> > > (see
> > >http://developer.android.com/guide/topics/resources/providing-resourc...
> > > )
> > > to make image specification like "drawable/myimage" similar to what we
> > > use in XML layouts?
>
> > > Reimplementing working mechanism doesn't look the right way :(
>
> > > Thanks.
>
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Developers" group.
> > > To post to this group, send email to [email protected]
> > > To unsubscribe from this group, send email to
> > > [email protected]
> > > For more options, visit this group at
> > >http://groups.google.com/group/android-developers?hl=en
>
> > --
> > Dianne Hackborn
> > Android framework engineer
> > [email protected]
>
> > Note: please don't send private questions to me, as I don't have time to
> > provide private support, and so won't reply to such e-mails.  All such
> > questions should be posted on public forums, where I and others can see and
> > answer them.

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

Reply via email to