views:

266

answers:

3

Hi All,

I have a jar that consists of a class that extends Activity and performs some activity on onCreate. I want to import this jar into my Android app and start the activity.

How can I go about this?

Thanks George

+1  A: 

Step #1: Put the JAR in your project's libs/ directory.

Step #2: If you are using Eclipse, add this JAR to your build path

CommonsWare
what if he's not using eclipse?
Lo'oris
Ok. After that, can I just create an Intent object and supply the package name and class name, and then call the startActivity?
Ron
you also have to add the Activity to your mannifest file.
darren
A: 

I got this working. I put the JAR in the assets folder, and didnt have to set the build path. Thanks a lot!

Chris
A: 

i had the same problem as mentioned above and with your tip i got i working. thanks.

but unfortunately, all resource files can't be found while loading the activity from the jar file. at the first occurence of loading a res file there is a ResourceNotFoundException:

04-30 11:18:46.944: ERROR/AndroidRuntime(1749): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f040006

any hints for that?

Roflcoptr
Don't think you can use resources from the jar, infact, you want to pack only your source code in the jar. In my case, I had a resource file that contained the layout, so I just chose to create the layout programatically instead of using the XML.
Ron