James
James

Reputation: 51

Open an activity without declaring it in the manifest file in ANDROID?

I want to open an Activity without declaring it in a manifest file.
I don't know if it is possible or not.
What I actually want is to dynamically open an Activity from my program using Intents. Can anyone help me if it is possible.

Upvotes: 5

Views: 3498

Answers (3)

ValiSpaceProgramming
ValiSpaceProgramming

Reputation: 519

I tried this very long, but since the Instrumentation class uses the IActivityTaskManager, which is a class of the internal API located at com.android.server.wm, that is not in the Activity classloader, I solved this by another method:

Using a subclass

I just made an Gist, with sample code.

GIST

Upvotes: -2

Muneeb Mirza
Muneeb Mirza

Reputation: 920

Your 'Dynamic' activity start is actually the normal way of starting an activity (as you have said in a comment to the answer of Matt M). Though you HAVE to add the Activities in manifest as Matt M said. In list view, clicking an activity will call a function that will start respective activity with startActivity() function.

Upvotes: 1

Matt M
Matt M

Reputation: 814

Not possible. Although I am unsure what you mean "dynamically open an activity".

See: http://developer.android.com/reference/android/app/Activity.html

Under Class Overview it states "To be of use with Context.startActivity(), all activity classes must have a corresponding declaration in their package's AndroidManifest.xml"

You can have an Activity in your package and not define it in the manifest, however you would not be able to start it successfully.

Upvotes: 4

Related Questions