0

Hi I am working with android.I had created a library project. Now I integrated it with my new app. Now how can I access the library main class to my new project ???

Manoj Varma
  • 70
  • 1
  • 12

2 Answers2

1

Its depend on your Library project. How you have create it. Mean pure java file or you have use some other resources also.

Simply refer official document here. & Other reference link is here.

You can use that Class using importing package , Like i have one lib and i have added as lib project and i am importing that lib package as below.

import chintan.khetiya.android.my_custom_lib.*;

If you have use <activity>, <service>, <receiver>, <provider>, and so on, as well as <permission>, <uses-library>, any of these then you have to add all of these in your real project. See For More Details

Community
  • 1
  • 1
Chintan Khetiya
  • 15,962
  • 9
  • 47
  • 85
  • I had created an android project and is marked as library.. now ho can I access its features in my new project after integrated it??? – Manoj Varma Feb 18 '14 at 11:47
  • As i have already told you , like in my lib `DBHelper.java` is a class now if i want to use this then first add that lib project in my new project and use your class they will ask about importing package.That's it – Chintan Khetiya Feb 18 '14 at 11:49
  • is it possible to access oncreate actions in my library project from my new app?? – Manoj Varma Feb 18 '14 at 11:53
  • for that you have to make an Interface and that will call your event whenever you want check this http://stackoverflow.com/questions/3398363/how-to-define-callbacks-in-android – Chintan Khetiya Feb 18 '14 at 11:54
  • http://stackoverflow.com/questions/5046864/android-library-project-and-activities check this also – Chintan Khetiya Feb 18 '14 at 12:14
0

If you use eclipse;

Right click your project in "Project Explorer" view, than open window select "Android" tab left side. At right side bottom container you will see "add button" click and select project.

""Your library and project in same workspace.""

nurisezgin
  • 1,530
  • 12
  • 19
  • I already done it.I had used the code startActivity(new Intent(MainActivity.this, MainActivity1.class)); to access the library project oncreate in my onclick action of a button in new project but it force closed – Manoj Varma Feb 18 '14 at 12:00
  • You will declare your manifest.xml library's activity. Because library project have not context. – nurisezgin Feb 18 '14 at 12:02
  • What's your log cat detail? Could you post it? – nurisezgin Feb 18 '14 at 12:05