Using an Android library project Activity within another project

Solution 1:

I believe you must include the <activity> in your own AndroidManifest.xml -- I don't think it gets picked up from a library. I don't have my reference for that handy.

Update: It's official solution. From the doc:

Declaring library components in the manifest file

In the manifest file of the application project, you must add declarations of all components that the application will use that are imported from a library project. For example, you must declare any <activity>, <service>, <receiver>, <provider>, and so on, as well as <permission>, <uses-library>, and similar elements.

Declarations should reference the library components by their fully-qualified package names, where appropriate.

Solution 2:

Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
intent.setComponent(new ComponentName("packagename//ex-com.hello", 
                                     "classname//ex-com.hello.ExampleActivity"));
startActivity(intent);

And make sure in library you have declared the activities. You don't need to declare the library activities in your current project's manifest.

Solution 3:

did you add to the manifest?

http://developer.android.com/guide/topics/manifest/uses-library-element.html

Solution 4:

This works:

In your library, put your custom Activity:

public class MyLibraryActivity extends ListActivity { ... }

No need to put it into a manifest. In your calling Android project, create an empty (dummy) wrapper:

public class MyActivity extends MyLibraryActivity { } 

and add reference to this class to your manifest:

<activity android:name="my_package.MyActivity" ... />

Solution 5:

I am aware that the question is quite old but I think this might help people like me that came up with the same problem.

Using Eclipse, the best way to share code and activities among libraries is probably the one that can be found in the android documentation here:

Managing Projects from Eclipse with ADT