What is the [Application] in Mono for Android?

I am new to mono and working on Mono tutorials for Android. Can someone point me to some kind of documentation that explains the meaning of the [Application] tag over my classes? ... Here is my problem:

I ran into a problem when I created two separate classes, App1.cs and App2.cs, both of which extend the application class (Public Class App1: Application), etc.

There is a tag above this ad [Application], which seems to cause deployment problems, although it works great. If I comment on one of them, the application builds and deploys perfectly.

I searched for information about these tags, but so far have not found anything in the search, frequently asked questions or google ... I think that the square brackets cause problems with the search. Any help would be great ...

thanks

FROM

+2
source share
1 answer

In Android applications, you can subclass the Application class to maintain global state in your application. An application can have no more than one Application class, and it is available to the entire application. To register your Application class, you must register it in AndroidManifest.xml (this applies to any Android component). Mono for Android uses attributes to generate a manifest at compile time, so any class decorated with ApplicationAttribute will generate a configuration at build time.

Since only one Application class is allowed, this explains the problems you see when you try to register two of them. My guess (without context is what you're trying to do here) is that you probably want Activity subclasses for these classes instead of Application .

+5
source

Source: https://habr.com/ru/post/911200/


All Articles