So I would like to make a free app with full functionality loaded in. The pro functionality will be disabled until the app detects a licensed pro key. And of course I would like to have the pro key check it’s licence using LVL. While I know how to do things right until this point, I don’t know how to make the pro key communicate with the app that it should enable the pro functionality.
Here’s the main app code (com.test.mainapp):
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
context = getApplicationContext();
final PackageManager pacman = getPackageManager();
final int signatureMatch = pacman.checkSignatures(getPackageName(),
"com.test.mainapp_key");
if (signatureMatch == PackageManager.SIGNATURE_MATCH) {
Toast.makeText(context, "Pro key detected!", Toast.LENGTH_SHORT)
.show();
} else {
Toast.makeText(context, "Free version", Toast.LENGTH_SHORT).show();
}
}
While this stops others making fake keys for my app, they still can share the key app online to others and it will work. Because we can’t do the LVL check from another application, I would want the licence key app check it’s own licence and if it’s correct, only then the user gets the pro functionality. How can I have the licence key app and the main app communicate to each other like this?
The functionality I’m trying to get here is like Titanium Backup does, for example.
You can send intents between the main app and the key app. If you are using LVL in the key app then an example callback would be:
You would set up broadcast receivers in both apps to initiate the license check and handle the result. e.g.
You should limit access to the intents using certificate based permissions to prevent other apps being able to send spoofed “License Success” intents.
http://developer.android.com/reference/android/content/BroadcastReceiver.html#Permissions
Short version.
Define permission in manifest
Use Permission in receiver declaration: