Platform helpers
The static Platform
class, in the Microsoft.Maui.ApplicationModel namespace, contains helpers for each platform.
The Platform
class contains the following helpers on Android:
Member | Purpose |
---|---|
ActivityStateChanged |
An event that's raised when any Activity's state changes. |
AppContext |
A property that gets the Context object that represents the current app context. |
CurrentActivity |
A property that gets the current Activity object that represents the current activity. |
Intent |
A static class that contains the ActionAppAction string, which is the identifier for the Intent used by app actions. |
OnNewIntent |
Pass an Intent from an activity's overridden method, when invoking an app action. |
OnResume |
Pass an Activity from an activity's overridden method, when an Activity is resumed as part of invoking an app action. |
OnRequestPermissionsResult |
Pass permission request results from an activity's overridden method, for handling internal permission requests. |
WaitForActivityAsync |
Wait for an Activity to be created or become active. |
The following example shows how to access the current Context
or Activity
for the running app:
var context = Platform.AppContext;
// Current Activity or null if not initialized or not started.
var activity = Platform.CurrentActivity;
If there's a situation where the Activity is needed, but the app hasn't fully started, call the WaitForActivityAsync
method:
var activity = await Platform.WaitForActivityAsync();
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for