How to integrate .NET MAUI Circular ProgressBar with android native embedding application?
In this article, learn to create a .NET MAUI Circular ProgressBar native embedded Android application by following these steps.
Step 1:
Create a .NET Android application and install the Syncfusion.Maui.ProgressBar NuGet package using the nuget.org.
Step 2:
In the project file of the native application, add <UseMaui>true</UseMaui> to enable the .NET MAUI support as demonstrated as follows.
<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.
Use the Build() method on the MauiAppBuilder object to build a MauiApp object. From the MauiApp object, create a MauiContext object. Convert .NET MAUI controls to native types using 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 a new instance for the SfCircularProgressBar control, and set the progress value and segment count with the respective properties; Progress and SegmentCount.
public class MainActivity : Activity
{
MauiContext? _mauiContext;
protected override void OnCreate(Bundle? savedInstanceState)
{
SfCircularProgressBar circularProgressBar = new SfCircularProgressBar { Progress = 75, SegmentCount = 4 };
}
}
Step 5:
Convert the circular progress bar control to a platform-specific view for the MAUI framework and set this view as the content view for the current Android activity.
protected override void OnCreate(Bundle? savedInstanceState)
{
Android.Views.View view = circularProgressBar.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 Android Native embedding for the .NET MAUI Circular ProgressBar.
Refer to our .NET MAUI Circular ProgressBar’s feature tour page for other groundbreaking feature representations. You can also explore our .NET MAUI Circular ProgressBar documentation to understand how to present and manipulate data.
For current customers, check out our .NET MAUI from the License and Downloads page. If you are new to Syncfusion®, try our 30-day free trial to check out our .NET MAUI Circular ProgressBar and other .NET MAUI components.
Please let us know in the following comments section if you have any queries or require clarification. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!