Thanks again Dianne, i don't think your solution will do as i also need to know which class i am in (i need to know that 0x7f020000 is a drawable and that 0x7f030000 is a layout). Is it possible to get the information i need through the AssetManager? any way to hack into the binary data structure? if not i guess it is back to the drawing-board for me.....
On Mon, Aug 24, 2009 at 3:09 AM, Dianne Hackborn <[email protected]>wrote: > Sorry but this just isn't something we have APIs for right now. I don't > recall anyone wanting to do this kind of thing before, so it hasn't been > high on our priority list. > > Note that "layout" etc at the resource level are not really folder names -- > they are just symbolic names for the part of the resource identifier integer > that categorizes the resource. The resource system itself revolves almost > entirely around integer identifiers; the symbolic names are pretty much just > there for the convenience of developers. There is a big binary data > structure in the .apk that is used to map from integer identifiers to the > corresponding resource value (which may be stored directly inside the data > structure for simple resources like integers and strings, or may be a path > to another file in the .apk for things like xml data or images). > > You could probably hack something together by taking advantage of the > current implementation detail that the resource system assigns resource > identifiers in a sequential manner (sequentially incrementing the entry part > and type part of the integer), to step through retrieving names until you > get a resource not found exception. However, I can't make any guarantees > that this will work in the future. > > On Sun, Aug 23, 2009 at 3:44 PM, Spektor Yaron <[email protected]> wrote: > >> Hi again, >> just to verify that i am explaining myself correctly. my code takes all >> the relevant apk's based on the intent filter and wants to take all the >> resources from the \layout to later be able to inflate them. >> i get the package name (e.g.,"com.android.demo.notepad2") from the >> returned resolveInfo and i know the folder name (e.g., layout etc.) all i >> need now is a method to get all the resources in something like: >> "com.android.demo.notepad2:layout" on a diffrent apk. >> thanks >> >> >> On Mon, Aug 24, 2009 at 12:18 AM, Spektor Yaron <[email protected]>wrote: >> >>> Hi, >>> i know it is done somehow by other applications (for example adding new >>> skins to an existing application w/o knowing the name of the layout ahead of >>> time) >>> what am i missing here. is this not the way to do it? >>> should i copy all resources to the file system and read them from there? >>> would that make sense? would i be able to inflate a view with them this way? >>> Thanks, >>> >>> >>> On Sun, Aug 23, 2009 at 6:44 PM, Dianne Hackborn <[email protected]>wrote: >>> >>>> I don't believe there is any way to do that from an application. From a >>>> desktop, you can use the aapt dump commands to find out about the contents >>>> of the .apk. >>>> >>>> >>>> On Sun, Aug 23, 2009 at 8:15 AM, Spektor Yaron <[email protected]>wrote: >>>> >>>>> Hi, >>>>> i was able to play around with the resource on a different apk and get >>>>> them using createPackageContext as you suggested. >>>>> here is an example of the code: >>>>> otherAppContext = >>>>> this.createPackageContext("com.android.demo.notepad2",Context.CONTEXT_INCLUDE_CODE >>>>> + Context.CONTEXT_IGNORE_SECURITY); >>>>> int resID = otherAppContext.getResources().getIdentifier("icon", >>>>> "drawable", "com.android.demo.notepad2"); >>>>> >>>>> this works well. >>>>> now i am trying to get ALL the drawables (or all the layouts) in this >>>>> package. i tried a multitude of ways including reflection and AssetManager >>>>> but was unsuccessful. any tips here? >>>>> just to be clear i can not use R.drawable.icon as this is a different >>>>> context >>>>> >>>>> -- >>>>> Yaron Spektor >>>>> >>>>> >>>>> >>>> >>>> >>>> -- >>>> 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. >>>> >>>> >>>> >>>> >>> >>> >>> -- >>> Yaron Spektor >>> >> >> >> >> -- >> Yaron Spektor >> >> >> > > > -- > 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. > > > > > -- Yaron Spektor --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

