How to integrate .NET MAUI Scheduler with Android Native Embedding Application?
In this article, you can learn the process of integrating the .NET MAUI Scheduler into an Android native embedding application. Follow this step-by-step guide to seamlessly incorporate the Scheduler in your project.
Step 1:
Create a .NET Android application and install the Syncfusion.Maui.Scheduler NuGet package from the nuget.org.
Step 2:
In the project file of the native application, add the tag <UseMaui>true</UseMaui> to enable .NET MAUI support.
<PropertyGroup>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseMaui>true</UseMaui>
</PropertyGroup>
Step 3:
Creating a MauiAppBuilder object and using the UseMauiEmbedding function is the standard procedure for initializing .NET MAUI in a native app project.
To build a MauiApp object, use the Build() method on the MauiAppBuilder object. From the MauiApp object, you need to create a MauiContext object. Converting .NET MAUI controls to native types will require the use of the MauiContext object.
MauiContext? _mauiContext;
protected override void OnCreate(Bundle? savedInstanceState)
{
base.OnCreate(savedInstanceState);
MauiAppBuilder builder = MauiApp.CreateBuilder();
builder.UseMauiEmbedding<Microsoft.Maui.Controls.Application>();
builder.ConfigureSyncfusionCore();
MauiApp mauiApp = builder.Build();
_mauiContext = new MauiContext(mauiApp.Services, this);
}
Step 4:
Create an instance of the SfScheduler control, configure it, and set the appointment collection to the AppointmentsSource property.
SfScheduler scheduler = new SfScheduler();
scheduler.View = SchedulerView.Week;
var appointment = new ObservableCollection<SchedulerAppointment>();
//Adding scheduler appointment in the schedule appointment collection.
appointment.Add(new SchedulerAppointment()
{
StartTime = DateTime.Today.AddHours(13),
EndTime = DateTime.Today.AddHours(15),
Subject = "Client Meeting",
});
//Adding the scheduler appointment collection to the AppointmentsSource of .NET MAUI Scheduler.
scheduler.AppointmentsSource = appointment;
Step 5:
Convert the Scheduler control to a platform-specific view for the MAUI framework and set it as the content view for the current Android activity.
protected override void OnCreate(Bundle? savedInstanceState)
{
...
Android.Views.View view = scheduler.ToPlatform(_mauiContext);
// Set our view from the "main" layout resource
SetContentView(view);
}
Output:
Download the complete sample on GitHub
Conclusion:
I hope you enjoyed learning how to integrate the .NET MAUI Scheduler with Android native embedding application.
You can refer to our .NET MAUI Scheduler’s feature tour page to learn about its other groundbreaking feature representations. Explore our .NET MAUI Scheduler documentation to understand how to present and manipulate data.
For current customers, you can check out our .NET MAUI from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our .NET MAUI Scheduler and other .NET MAUI components.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!