4

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

Ron
  • 67
  • 1
  • 2
  • 6

2 Answers2

8

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
  • 986,068
  • 189
  • 2,389
  • 2,491
  • 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 Apr 23 '10 at 22:50
  • "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 Apr 23 '10 at 23:31
  • 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 Apr 24 '10 at 01:16
  • 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 Apr 24 '10 at 01:42
0

I think you also need this inside of the filter:

    <category android:name="android.intent.category.DEFAULT" />
Dave
  • 2,546
  • 6
  • 23
  • 29