Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrating another android app inside my own application

I'm a total newbie to Android app development, so do excuse the lengthy explanation. Anyways, I have already developed my application (running successfully). Now, I want to integrate an open source app (quiz) into my application. So, when user presses a button in my app, it will then run the quiz application.

I have learnt from here (answer by Denys Nikolayenko) that there is a way to do it by converting the quiz app into .jar file, and adding it into my current project. I have already done that; to the point of adding the .jar file to Build Path (and it appears in Referenced Libraries) as stated here. Plus, the .jar file is also checked under the 'Order and Export' tab.

Now, I have a problem with integrating the .jar file into one of my button (so that the quiz app runs when I press the button, as mentioned earlier). Is there a way to integrate a .jar file in a button (I couldn't find any sample code anywhere)? Or is this concept of executing a .jar file wrong all-together?

If the concept is wrong, how do I integrate the quiz app into my app? I'm using Eclipse.

like image 207
natnirus Avatar asked Feb 17 '23 12:02

natnirus


1 Answers

I have learnt from here (answer by Denys Nikolayenko) that there is a way to do it by converting the quiz app into .jar file, and adding it into my current project.

That will be insufficient, in all likelihood. A JAR file only contains code, not Android resources, and the other app probably has some resources.

I have already done that; to the point of adding the .jar file to Build Path (and it appears in Referenced Libraries) as stated here.

The answers on that question have been out of date for over a year. Just add JARs to your project's libs/ directory, and do not modify the build path manually.

Is there a way to integrate a .jar file in a button (I couldn't find any sample code anywhere)? Or is this concept of executing a .jar file wrong all-together?

It is "wrong all-together".

If the concept is wrong, how do I integrate the quiz app into my app?

Personally, I would recommend against doing it in the first place, if you are "a total newbie to Android app development". I would recommend that you spend more time getting familiar with Android first.

If you insist upon doing this:

Step #0: Undo everything you did so far (e.g., putting the JAR in your project)

Step #1: Do one of the following:

  • Copy all of the Java source code and all of the resources from the other project into your own, or

  • Convert the open source project into an Android library project, then attach that Android library project to your own app's project

Step #2: Add relevant entries from the other project's manifest into your own app's manifest, such as <activity> elements and <uses-permission> elements.

Step #3: As needed, such as from your proposed button click, call startActivity() to start up an activity from the other project, rather than starting up one of your own projects.

like image 92
CommonsWare Avatar answered Apr 02 '23 16:04

CommonsWare