2

We all can import an existing Android project into workspace using File->Import->Existing projects into workspace. Is there any such method to include an existing java file( Activity) into a project.

For example if I have activity hello.java in project P1. Can I copy hello.java in project P2 in src/ folder and then import into the project somehow?

What I do normally in such cases is create a new class in Project P2 and copy the code from hello.java from P1 manually. Is there any better approach?

I am using Eclipse as editor.

Regards,

1 Answer 1

1

You can just right click on your hello.class from Project1 and select COPY , than go to your Project2's src folder and right click --> select PASTE and that's it.As I know that's the easiest way to do that.I'm not really sure if you can import classes from other Projects.You can create a library project and just include it to your current project. This way you will need to write a code once and you will be able to use it from all your application that you need. You just have to include it to your project's properities on Eclipse. That's it.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Android-Droid, This one looks good. Let me see If i find some better option if possible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.