8

Is there an outline or primer of how you would develop an app that has "add-ons"?

E.g., how to develop some sort of framework for adding "themes" to an app?

There is the basic app with 2 themes. The user should be able to download another app for a certain theme.

How does the original app and the new downloaded app talk together?

How would you develop the original app to get the theme information and graphic assets from the 2nd theme only app?

My understanding is that apps are completely separate so this is why I am unclear how to accomplish this.

Jonathan Soifer
  • 2,715
  • 6
  • 27
  • 50
Camille Sévigny
  • 5,104
  • 4
  • 38
  • 61

2 Answers2

6

How does the original app and the new downloaded app talk together?

For a theme, who says they have to talk together?

How to would you develop the original app to get the theme information and graphic assets from the 2nd theme only app?

Step #1: Pick a naming convention for your packages. For example, if your base app is com.abc.app, your themes could be com.abc.app.theme.*.

Step #2: When it comes time for the user to pick a theme, use PackageManager and getInstalledApplications() to find your themes by checking their package names.

Step #3: When it comes time to use a theme, call getResourcesForApplication() on PackageManager to get the theme application's Resources, so you can get at your stuff.

I am sure that there are strategies (e.g., the theme is mostly a conveyor, deploying its stuff in a directory on external storage, from which your main app reads the information), but this is the one I'd start with, as it should require the least user intervention.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Regarding: "getResourcesForApplication() on PackageManager to get the theme application's Resources"...You can do this to applications outside of your own? Are there some sort of security features that I need to implement to ensure that only my app can get to those resources and no other 3rd party apps can get access? This would be the missing piece I think that I would need in order to get started. – Camille Sévigny Jan 06 '12 at 20:33
  • 1
    @CamilleSévigny: "You can do this to applications outside of your own?" -- yes. "Are there some sort of security features that I need to implement to ensure that only my app can get to those resources and no other 3rd party apps can get access?" -- all resources of all apps are readable by all apps, whether you like it or not. – CommonsWare Jan 06 '12 at 20:34
  • "all resources of all apps are readable by all apps, whether you like it or not."...No kidding. I had no idea. Thanks for your responses. – Camille Sévigny Jan 06 '12 at 20:47
  • @CamilleSévigny: Yeah, it shocked the heck out of me when I first realized it. – CommonsWare Jan 06 '12 at 21:12
  • I have tested this out (creating a package with resource images, etc) and then reading the package resources from the main app. This works great! :) – Camille Sévigny Feb 01 '12 at 16:43
  • Is there any sample application which had used this method for its themes? – Mohammad Reza Norouzi May 22 '14 at 05:02
0

I believe the cleanest design in this case would be to have a single app in Market, and have the themes available on your own server. Then the user could download the app just once from Market, and then apply the themes available on your server.

However, if you prefer to have them as separate Market entries, you can set the android:sharedUserId flag on the manifest to make all of them run under the same user ID, which will allow you to share files (bitmaps, etc) between them. Remember they all have to be signed with the same certificate.

What may be confusing to the user is that they will be able to download an add-on before downloading the main app... in which case you'd have to display an error message asking them to download the main app.

Bruno Oliveira
  • 5,056
  • 18
  • 24
  • I agree with the "have the themes available on your own server" approach -- I was assuming the OP had considered and dismissed that for some reason. However, `sharedUserId` is risky, as any change in it means your app can no longer read its own files. – CommonsWare Jan 06 '12 at 19:08
  • Would `sharedUserId` also work for making a "Full" version app that just acts as a key for the main app, to enable features? – Izkata Jan 06 '12 at 19:27
  • There is no "server" lol. I would agree that downloading from an outside source would be nice, but this isn't an option. I am trying to emulate other apps on the market where you see "Theme XXX For App YYY". These are not complete apps but add-ons for them. – Camille Sévigny Jan 06 '12 at 20:23
  • The SharedUserID option looks good. I'll research and accept answers as soon as I can. – Camille Sévigny Jan 06 '12 at 20:25