21

Could someone describe me a solution to implement a plugin inside an Android application and how could it be sold on the Android Market?

Typically, you create a game whose 4 first levels are free. Then, the user should buy something using the Android Market to unlock additional levels.

A solution could be to list the packages set up on the phone which are named com.company.myApp.additionalLevelSet1 but it doesn't seem secure at all! (a user could manually set up the plugin packages and so unlock additional features freely)

On iPhone, you could use InAppPurchase to buy non-consumable or consumable products.

Any help or suggestion would be appreciated. Thanks!

Prof. Falken
  • 24,226
  • 19
  • 100
  • 173
Sly
  • 2,105
  • 5
  • 22
  • 28

2 Answers2

28

It's quite simple in your case, since you don't need any extra logic, but just more levels, so I will stick to this specific case:

You can (or probably already do) have your game levels saved as resources in your .apk, so a plug in can be a standard .apk, that will not appear in the list of users-apps. To prevent it from appearing, simply don't declare the category-launcher:

<intent-filter>
   <action android:name="android.intent.action.MAIN" />
   <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

Once the snippet above does NOT appear in your plugin's AndroidManifest, it will not be directly accessible to the user.

When your main game activity starts, it should check for the existence of plugins, you can do it, by calling PackageManager.queryIntentActivities. And querying for a specific intent you declared in the AndroidManifest file of your plugin, for example:

<intent-filter>
  <action android:name="com.your.package.name.LEVEL_PACK" />
</intent-filter>

The query code would then be:

PackageManager packageManager = getPackageManager();
Intent levelsIntent = new Intent("com.your.package.name.LEVEL_PACK");
List<ResolveInfo> levelPacks = packageManager.queryIntentActivities(levelsIntent, 0);

There are more ways to do this, but this is quite trivial and straight forward.

The last step is to access the levels from the installed level-packs. You can do this by calling: PackageManager.getResourcesForActivity and load the relevant resources and use them as you will.

Lior
  • 7,845
  • 2
  • 34
  • 34
  • Thanks for your answer that is cleared about the process. However, do you know if a solution exists to counter a user that would find the plugin APK, install it manually and then get the additional levels freely ? Maybe it's a stupid question... – Sly Jan 26 '11 at 11:34
  • This is a much more generic question - as far as I know there is no game/application that is "uncrackable", the most secured way is to have your own server and the app will check against it if the levels installed... And every levels pack installed should report to the server... Huge overkill of course :) – Boris Churzin Sep 04 '12 at 11:49
  • 1
    @Lior: Can you list other ways for the above problem ? – kAnNaN Apr 01 '13 at 07:45
  • @kAnNaN Mark Murphy talks about plugin architectures in this talk: http://www.youtube.com/watch?v=Xu8Z_3TaWuE (slides https://s3.amazonaws.com/misc.commonsware.com/slides/2013-xda/index.html#1). I think Lior is talking about something like that – Jose_GD Dec 11 '13 at 20:40
  • 1
    what about if we need extra logic ? like new methods, classes ... ? – Francisco Corrales Morales Apr 22 '14 at 22:15
0

What I've seen so far on the Android Market are entirely different version of apps for free versus paid content of the same application.

I haven't looked into plug-ins yet so I don't know if this feature is available, but if you can't find it a workaround could be to launch applications and hide them from the add application to home menu and/or shortcut menu and just add a link to it inside the main application.

Another workaround is to treat your additionnal content like paid content libraries and simply block the level access if the resource is not accessible. But you have to verify if you have a right to have private librairies that are separate from your application.

Basically what you're looking to do is exactly what content hosters like Apple and Android are trying to avoid or control since it would allow you to stream new content to your app without the content host knowing it's actually new content for another app.

I suggest you read this to understand why a multiple app-app isn't obvious in Android : Android Security

ahodder
  • 11,353
  • 14
  • 71
  • 114
Gepsens
  • 673
  • 4
  • 14