You can't really do this by simply pointing to a theme. The resources object is used across the view hierarchy to load resources; to set the theme from another apk you will need to have the resources coming from there, but then you won't be able to access any of your own resources that you need (like strings etc).
On Wed, Aug 1, 2012 at 2:38 PM, Mor G. <[email protected]> wrote: > Hi Richard, thanks for the reply. > > I have an app with light and dark themes defined in themes.xml. > I have a setting to allow the user the select light/dark theme in the app. > This works great. > > Now the themes are pretty heavy in graphics, since they define not only > styling but different drawables as well, so I want to offer more themes > like blue, green, red, etc. as external apks in Google play, like I've seen > many other apps have done, so a user could install a "MyApp blue theme" > apk, and then he'll be able to choose this theme from the main app settings. > > I've tried using: Resources res = pm.getResourcesForApplication(appInfo); > Which gets the resources object of the external apk, but I can't seem to > get and apply the theme from it using activity.setTheme(externalTheme). > > I've tried using: Context themedContext = > activity.getApplicationContext().createPackageContext("com.myapp.blue", > Context.CONTEXT_IGNORE_SECURITY); > Which gets a themed context, but again, couldn't set this theme to my > running activity. > > I've read a lot about this, but couldn't find any complete solution. > > Thanks, > Mor. > > > On Thursday, August 2, 2012 12:17:40 AM UTC+3, RichardC wrote: >> >> If it's your own application then read about library projects. >> Otherwise unless the app you are reading resources from is available >> under a suitable open source licence then in my opinion what you are trying >> to do could be infringing copyright. >> If the app is open source then just download it and use the resources. >> >> On Thursday, April 5, 2012 6:51:58 PM UTC+1, Terry wrote: >>> >>> I'm able to use getResourcesForApplication and getIdentifier to get the >>> individual resources from another application. However, when I try to call >>> setTheme using a remote theme.xml from another app, the references inside >>> theme.xml point to the app that I'm running, not pointing to the remote >>> application where the theme.xml is. As a result, I get a >>> ResourceNotFoundException inside theme.xml where I try to use the styles I >>> defined from the remote app. In other words, I can apply theme.xml but not >>> reference to the styles inside it. >>> >>> Moderator, please don't block this post. I googled for days and have not >>> found a resolution to it. >>> >> -- > 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

