views:

478

answers:

3

Hi all,

I have an android application that starts an activity and is running well. I need other developers to be able to integrate my APK into their applications in such a way that they can start the activity in my APK from their android applications.

What are the ways of achieving this?

Thanks George

+1  A: 

The best thing to do, IMHO, is declare a custom action in an in your activity's manifest. Something like:

<activity android:name="Foo">
  <intent-filter>
    <action android:name="com.commonsware.android.THIS_IS_MY_ACTION" />
  </intent-filter>
</activity>

Then, your compatriots can launch it via that custom action:

startActivity(new Intent("com.commonsware.android.THIS_IS_MY_ACTION"));

By namespacing your action, you should not run into accidental conflicts with anyone else's app.

CommonsWare
Thanks for the suggestion. I will try it and get back. Also, how do you bundle the package in such a case? Do I just make my signed APK available to other developers to integrate? Will I have to share my private key (with which I sign my APK) with the other developers?
Ron
"Also, how do you bundle the package in such a case?" You don't. They are two separate applications, by the way you described them. "Do I just make my signed APK available to other developers to integrate?" You can, but you also need to make it available to end users (e.g., through the Market), and the other developers will need to take steps to make sure that your app is there (e.g., use `PackageManager`). "Will I have to share my private key (with which I sign my APK) with the other developers?" No, and you really don't want to do that.
CommonsWare
Sorry for the confusion, I am a newbie to Android. I don't want to make my APK available to end users. All I want is to have a set of trusted developers be able to integrate it with their android applications. In this case, should I just create a signed APK and hand it over to them?
Ron
What you want is impossible, sorry. The best you can do is package your stuff up in a JAR file for them to include as a library. APKs cannot be embedded in other APKs.
CommonsWare
A: 

So can I just package my android application as a jar and hand it over? In that case, will they just be able to include my jar, and create an object of my class to start the activity?

George