I had the code in my start up (splash) activity, so yes it was in the
proper (as far as I know of) Context.

Yes, I did try to use the Resources.getSystem() verbatim. What
"normal" Resources object are you referring to? In other words, if you
cannot do:

mResources = Resources.getSystem();

Then what would be to the right of:

mResources = ?????

Actually, if it is too much of a pain don't worry about it. I've
already worked around this the old fashioned way by using a Map to
relate my image name to the R.drawable.image(s) that I have and
although cumbersome, works just fine.

I really do appreciate the effort trying to help though! :)



On Dec 18, 8:09 pm, Dianne Hackborn <[email protected]> wrote:
> I don't know what to say, the code I pointed to is exactly what has been in
> the platform fairly unchanged since 1.0 and has worked fine.
>
> Are you sure you are doing this on a Context that is actually for your
> application?  The error message ("Invalid package identifier") indicates it
> doesn't know *anything* about your application.
>
> Also I wasn't pointing this code as something to directly copy and paste,
> but as a guide.  It comes from really deep down in the framework, so it is
> not written as normal application code.
>
> In fact if you copy and pasted the Resources.getSystem() part, that would be
> your problem, because that is an API one doesn't normally use to get the
> system-only resources.  You should use the normal Resources object in your
> app.  (That's why the link I provided went directly to just the line pulling
> out the resource data.)
>
>
>
> On Sat, Dec 18, 2010 at 4:47 PM, darrinps <[email protected]> wrote:
> > This was just an example that fit the example you provided. I trimmed
> > down the array to only one .png file which I verified time  and again
> > was under the drawable directory and reworked the layout of the file
> > to match the example. The entire arrays.xml file which is found under
> > the values directory looks like this:
>
> > <?xml version="1.0" encoding="utf-8"?>
> > <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
>
> >     <array name="preloaded_drawables">
> >                <item>@drawable/aggies</item>
> >        </array>
> > </resources>
>
> > The same thing happens at the same line.
>
> > I get a warning first:
> > ResourceType    Invalid package identifier when getting bag for
> > resource number 0x7f050000
>
> > Then an exception:
> > Failure preloading resources
> >   android.content.res.Resources$NotFoundException: Array resource ID
> > #0x7f050000
> >   at android.content.res.Resources.obtainTypedArray(Resources.java:
> > 424)
>
> > The code is IDENTICAL. I copied and pasted it except for the preload
> > that I had to comment out.
>
> > On Dec 18, 1:02 pm, Dianne Hackborn <[email protected]> wrote:
> > > startPreloading() is not relevant to this; that is for the code there
> > that
> > > is preloading the drawables it gets from the array.
>
> > > Is there actually a sym_def_app_icon drawable in your app?  If not...
> >  well
> > > yeah, that won't work, it doesn't exist.
>
> > > You should just use the syntax I showed to make an array of references to
> > > your *own* drawables, which you can retrieve with the same code as shown
> > > using obtainedTypeArray().
>
> > > The last XML syntax you have shown is just not right, so it's not
> > surprising
> > > it doesn't work.
>
> > > On Fri, Dec 17, 2010 at 8:42 PM, darrinps <[email protected]> wrote:
> > > > Thanks.  I tried doing that but it seems to be an old API so I tried
> > > > to convert it to what is there today. There must be some mistake I
> > > > have made that keeps this from working.
>
> > > > Note that it didn't like mResources.startPreloading();   The method
> > > > simply was not there, although finishPreloading() is.  I commented the
> > > > startPreloading() line out.
>
> > > > Secondly, it didn't like the format of the array when it looked like
> > > > this:
>
> > > > <array name="preloaded_drawables">
> > > >         <item>@drawable/sym_def_app_icon</item>
>
> > > > So, I changed that to this:
>
> > > >     <array name="preloaded_drawables">
> > > >                <item type="drawable" name="sym_def_app_icon"></item>
>
> > > > When I execute this line:
>
> > > >             TypedArray ar =
>
> > mResources.obtainTypedArray(com.standardandroid.swarooms.R.array.preloaded_drawables);
>
> > > > I get a warning:
> > > > ResourceType    Invalid package identifier when getting bag for
> > > > resource number 0x7f050000
>
> > > > Then an exception:
> > > > Failure preloading resources
> > > >   android.content.res.Resources$NotFoundException: Array resource ID
> > > > #0x7f050000
> > > >   at android.content.res.Resources.obtainTypedArray(Resources.java:
> > > > 424)
>
> > > > Any idea what I am doing wrong?
>
> > > > On Dec 13, 1:41 am, Dianne Hackborn <[email protected]> wrote:
> > > > > I would recommend just having another resource holding an array of
> > the
> > > > > drawables to include.  See for example this declaring one:
>
> >http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;...
>
> > > > > <
> >http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;..
> > > > .>And
> > > > > this reading it:
>
> >http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;...
>
> > > > > Sure, it is one more step required when adding a resource, but at
> > runtime
> > > > it
> > > > > is going to be far more efficient than other solutions that require
> > > > scanning
> > > > > through resources or R symbols or such.
>
> > > > > On Sun, Dec 12, 2010 at 8:17 PM, darrinps <[email protected]>
> > wrote:
> > > > > > Is there any way for an Android app to read the file names of all
> > the
> > > > > > files stored under drawable (or for that matter any other
> > directory)?
>
> > > > > > I'd like to have it so I can plop in a new file and have the app
> > read
> > > > > > the name for me for use in a dynamically sized list of radio
> > buttons
> > > > > > (one button per file) that lists the name of the file by the radio
> > > > > > button.
>
> > > > > > I've done something like this with contacts, but I am not sure how
> > you
> > > > > > read the file names from something like the drawable directory!
>
> > > > > > Thanks.
>
> > > > > > Darrin
>
> > > > > > --
> > > > > > 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]<android-developers%[email protected]>
> > <android-developers%[email protected]<android-developers%[email protected]>
>
> > > > <android-developers%[email protected]<android-developers%[email protected]>
> > <android-developers%[email protected]<android-developers%[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]<android-developers%[email protected]>
> > <android-developers%[email protected]<android-developers%[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]<android-developers%[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