Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invoking activity from APK in another android application

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

like image 997
Ron Avatar asked Feb 28 '23 03:02

Ron


1 Answers

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.

like image 146
CommonsWare Avatar answered Apr 27 '23 19:04

CommonsWare