Using PackageManager you can query Activities/etc on the system in all installed packages(APKs). The ApiDemos sample code in the Android SDK uses this in the class com.example.android.apis.ApiDemos
.
Code example:
void findAddOnActivities() {
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory("myPackage.intent.category.ADDON");
PackageManager pm = getPackageManager();
List<ResolveInfo> list = pm.queryIntentActivities(mainIntent, 0);
// list contains all activities that match your filters in mainIntent
}
Manifest snippet:
<activity
android:label="My external Add-on"
android:name=".addons.TestAddon" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="myPackage.intent.category.ADDON" />
</intent-filter>
</activity>
For Database access and managing access/modify security:
Declare your own permissions in your manifest:
<permission android:name="com.mycompany.myapp.database.permission.READ"
android:label="@string/read_permission" android:protectionLevel="signatureOrSystem"></permission>
<permission android:name="com.mycompany.myapp.database.permission.WRITE"
android:label="@string/write_permission" android:protectionLevel="signatureOrSystem"></permission>
The protectionLevel tag will make sure that only APKs that are part of the image or are signed with the same key as the main app can be granted that permission.
There are many ways to have the addon access your database. A remote service or providing an interface would work. In the app I have that does this, my main app has a class called DBManager that already does a bunch of read/writes to the database. So I just use that class in my external App and it can do all the reads/writes since the packages are signed with the same key.
If you don't want to use the same key to sign packages, consider using a remote service like the one in the sample code RemoteService.java. Look at the android service dev guide for more details. I'm no expert on android Services, so any feedback from others would probably be helpful.