Is it compulsory to add a class file, which extends activity, to manifest?
I have created a java file for handling file IO and to use openfileoutput() openfileinput() i have extended Activity class.
YES you most declare it in the manifest so the application will know its activity.
If you use/call that class (which extends Activity) somewhere in your code, you MUST declare that class (Activity) in Manifest file. If you don't, you will get exception.
Manifest file is used to declared essential information for your app (Activity, Service, Broadcast Receiver, keys,...).
For more info about Manifest, you can check it here.
when you launch the application first the OS will check your manifest file.So if your Activity is not Listed in the Manifest file.Then it won't execute it.So your ACTIVITY class should be declared in the Manifest file.
Related
I need to add an activity tag for an external library I'm using, per their documentation, but when I do that using this code
<activity
android:name="com.adityaanand.morphdialog.MorphDialogActivity"
android:theme="#style/MorphDialog.Custom.Light">
</activity>
in my application tag, I get the error
Unable to find explicit activity class {com.jggdevelopment.simpleweather/in.adityaanand.morphdialog.MorphDialogActivity}; have you declared this activity in your AndroidManifest.xml?
How can I include an external library's activity in my manifest file?
This is the library.
All I had to do was change the activity name to in.adityaanand.morphdialog.MorphDialogActivity and it worked. I thought I had tried that already, but I guess not.
I have a library defining an abstract Activity. The app using this library extends the Activity, and therefore needs to add it to its AndroidManifest.xml.
The AndroidManifest.xml of the library gets merged to the one of the app following some rules.
However, I can't seem to find a way to declare my abstract activity in the AndroidManifest.xml of the library. I would like to set android:configChanges and android:launchMode in the base class instead of having to declare it in the manifests of all the subclasses.
Is that possible in some way?
In your manifest you only have to declare the Activities that are actually used by your application. You should declare the Activity that extends your abstract Activity.
To edit the configuration of your activities, you have to set these parameters for each of your concrete activities in your manifest.
Short answer; no.
From what I can find, the only way to set the android:configChanges and android:launchMode attributes is in the manifest. And the manifest only accepts the name of the class that you will be instantiating (i.e. the subclasses of you abstract class).
I am having two classes in my android project so, should I mention two activity tags in my app manifest file or will it work without including the activity tag.
Although, my app is working fine but I think this creates error - Unfortunately, your app has stopped working.
it depends Which kind of classes you have.. if your class is extending Activityor ActionBarActivity or AppCompatActivity or the class wich extends any of these, than you must define it in manifests.xml file. otherwise if your class extends nothing or just extends view, then no need to define it in manifests.xml file.
Yes,every Activity you used must be declared in manifests.xml,or when jump the activity,app will crash.
I have sub-folders(packages) defined in an application, which has to be defined in Manifest file accordingly.
But after defining as per the conventions and as suggested by patrons in their posts, the application crashes. The error again in the logcat is
"03-17 19:38:54.118: E/AndroidRuntime(558): android.content.ActivityNotFoundException: Unable to find explicit activity class {in.co.avksons/prox_analysis.prox_main_scr}; have you declared this activity in your AndroidManifest.xml?"
I tried to look in each file on the specifics of the package, but could not find the error.
What are the possible causes for not acknowledging the package definition in the manifest file.
Thanks
Can you post your Manifest file? I have a feeling you are referencing your Activity incorrectly.
If for example you have an activity called TestActivity, and it was under the folder Activities, and your package name was com.test.app then you would reference your activity as follows:
com.test.app.Activities.TestActivity
You cant use '/' in the manifest file, use '.' instead.
Most likely, you have wrong declaration of activiy in Manifest. If you have package "com.application.view", for example, declaration will be like this:
android:name=".view.Activity"
I want to open an activity without declaring it in an 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.
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.
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.
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