I am new to android. I am making an application for reading the pdf files. For this i want to integrate some existing open source apk with my application. Please suggest and give me example, how i can bind the apk with my application and how to call the apk from within the application activity. I think there should be something used by intent but not sure. Also if there can be any code to develop our own pdf reader, please share. Thanks.
3 Answers
As i know, integrating an apk directly from another application is not possible. This can not be achieved unless you know the source code of the apk. If this is the case. Now its like this if you want to invoke Application2 from Application1 then you have to add one more intent filter in the Application2, you have to define an action in Application2 Manifest like
<action android:name="com.app2.intent.action.INVOKE_APP2"/>
and then define intent in your Application1 as
Intent i=new Intent("com.app2.intent.action.INVOKE_APP2");
startActivity(i);

- 917
- 1
- 6
- 16
-
Thanks Neetesh, if i know the package and main activity of the apk then whether this is possible to call apk. – Rajesh Nov 30 '11 at 10:02
-
pls look into this, http://stackoverflow.com/questions/4674391/calling-an-app-from-another-app – Neetesh Nov 30 '11 at 10:08
It only possible if you know exactly what kind of intent (Action, data, type) the activities in that apk would be able to react.
You can use either startActivity(intent)
or startActivityForResult(intent)
once you know what the intent should be like.

- 39,805
- 37
- 135
- 175
-
-
do you mean requstCode paramters for startActivityForResult? That does not matter. As it is only used by you to identify the return value. – pierrotlefou Nov 30 '11 at 09:57
An APK is not source code. You cannot directly interact with it if it was not meant to allow this, through intents. If you're starting on Android, I suggest you take some time familiarizing yourself with intents and intent-filters, they're one of the "unique" aspects of Android development, and you can do quite powerful things when you know what you're doing.
http://developer.android.com/reference/android/content/Intent.html
But please note in order to do that, you need to have the user install both apps (the original apk and yours). As far as I know, there is no way to "embed" an apk within your own app.
Also, please have a look at that question and this one, they overlap a little bit what you're asking.