0

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?

JonasVautherin
  • 7,297
  • 6
  • 49
  • 95
  • 1
    *Is that possible in some way?* I don't think so ... I would: do the documentation how should be Activity derived from yours class declared in manifest, and do some check (with help of ActivityInfo) in onCreate, fx: check if Activity is declared with given launchMode/configChanges - if not throw runtime exception with some information, like *Acitivty Foo should be declare with "single top" launchMode* ... it will not work with "programmers" which not reading the exception at all (but pasting 'em here, on SO) – Selvin Jun 17 '16 at 12:55
  • I'll check if I can check those fields programmatically, as I could not find a way to set them. – JonasVautherin Jun 17 '16 at 13:01
  • I can check the values programmatically, indeed. I'd like to find a confirmation that the manifest merging thing is not possible, but that is the best answer otherwise, so you should write it as an answer =) – JonasVautherin Jun 17 '16 at 14:19

2 Answers2

2

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.

Vektor88
  • 4,841
  • 11
  • 59
  • 111
  • I know that I don't have to declare my abstract activity. The question is: can I do it if I want its declaration to be inherited by the concrete activities? – JonasVautherin Jun 17 '16 at 13:02
  • No, you have to define these configurations for each of your concrete activities – Vektor88 Jun 17 '16 at 13:36
0

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).

Community
  • 1
  • 1
Bryan
  • 14,756
  • 10
  • 70
  • 125