Using AppCompatActivity as Main Activity
In Crosslight Android apps, you typically need at least one Activity class for the main activity that represents the first view of your application. In Crosslight, this Activity is the one you set as root view model in AppService.cs inside the Core project as follows.
Here's the code for the Activity.
Customizing Modal Activity
In addition to main Activity, you can use Activity to represent a modal navigation, where the previous view state will be suspended while keeping the view state intact. Since the pattern is quite straightforward, Crosslight Android Material provides a built-in modal Activity so that you do not need to create Activity for each modal navigation in your application. You can simply use navigation service to navigate to a ViewModel that uses Fragment for its view.
The following code shows you how to perform modal navigation using the built-in navigation service and how to define the target fragment for your modal navigation.
Here's an example of the target Fragment.
When the navigation service is executed it will open a new modal activity with ItemEditFragment as its content. This is done automatically. If you want to customize this modal Activity, let's say you want to customize the theme for this modal Activity, you can do this by declaring an AppCompatActivity with the same associated target ViewModel as follows.
To see the AppCompatActivity in action, check out these samples: