In this article, you will learn how to use the .NET MAUI PDF Viewer in a native Android application to view PDF documents by following the step-by-step process outlined below: Step 1: Create a .NET MAUI class library project and delete the Platforms folder and the Class1.cs file from it. Then add the classes named EmbeddedExtensions, EmbeddedPlatformApplication, EmbeddedWindowHandler, and EmbeddedWindowProvider to the created .NET MAUI class library project. The required code for these classes is available here. Step 2: Next in the same solution, create a .NET MAUI single project. This project is used to register the handlers required to render the PDF viewer control. After including the project in the solution, follow the steps mentioned here Step 3: Install the Syncfusion.Maui.PdfViewer nuget package from nuget.org into the created .NET MAUI single project. Step 4: Register the core handler in the MauiProgram.cs file of the .NET MAUI single project by calling the ConfigureSyncfusionCore method. public static MauiApp CreateMauiApp<TApp>(Action<MauiAppBuilder>? additional = null) where TApp : App { var builder = MauiApp.CreateBuilder(); builder .UseMauiApp<TApp>() .ConfigureSyncfusionCore() .ConfigureFonts(fonts => { fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); }); Step 5: Create the native Android application project in which you want to add the PDF viewer and install the Syncfusion.Maui.PdfViewer nuget package from nuget.org. Step 6: In the project file of the native Android application, add <UseMaui>true <UseMaui> to enable the .Net Maui support demonstrated as follows. <PropertyGroup> <TargetFramework>net8.0-android</TargetFramework> <OutputType>Exe</OutputType> <Nullable>enable</Nullable> <UseMaui>true</UseMaui> <ImplicitUsings>enable</ImplicitUsings> <SupportedOSPlatformVersion>13.0</SupportedOSPlatformVersion> </PropertyGroup> Step 7: Initialize .NET MAUI in the native Android project by creating a MauiApp object and using the UseMauiEmbedding method in the MainActivity.cs file as follows. public class MainActivity : Activity { public static readonly Lazy<MauiApp> MauiApp = new(() => { return MauiProgram.CreateMauiApp(builder => { builder.UseMauiEmbedding(); }); }); public static bool UseWindowContext = true; private SfPdfViewer _pdfViewer; protected override void OnCreate(Bundle? savedInstanceState) { base.OnCreate(savedInstanceState); // Initialize the Maui app var mauiApp = MauiApp.Value; var _mauiContext = UseWindowContext ? mauiApp.CreateEmbeddedWindowContext(this) // Create window context : new MauiContext(mauiApp.Services); // Create app context …… …… } Step 8: Create a new folder with the name “Assets” in the Android app project and include the PDF document to be loaded, inside the folder. Set the Build Action of the PDF file to Embedded Resource. In this example, a PDF named “PDF_Succinctly.pdf” is used. Step 9: Create the .NET MAUI PDF viewer control, convert it to a native view, and add it as the Content of the OnCreate(). protected override void OnCreate(Bundle? savedInstanceState) { ….. ….. // Initialize and configure the SfPdfViewer _pdfViewer = new SfPdfViewer(); // Set the document source for SfPdfViewer control var assembly = Assembly.GetExecutingAssembly(); _pdfViewer.DocumentSource = this.GetType().Assembly.GetManifestResourceStream("NativeEmbeddingPDFViewerDemoAndroid.Droid.Assets.PDF_Succinctly.pdf"); // Convert SfPdfViewer to an Android view Android.Views.View pdfViewerView = _pdfViewer.ToPlatform(_mauiContext); // Directly set the pdfViewerView as the content view SetContentView(pdfViewerView); } Step 10: In the solution, set the native Android project as the start-up project. Build, deploy, and run the project. View the sample on GitHub Conclusion We hope you enjoyed learning how to integrate .NET MAUI PDF Viewer in a native Android application. Refer to our .NET MAUI PDF Viewer’s feature tour page to learn about its other groundbreaking feature representations. You can also explore our .NET MAUI PDF Viewer Documentation to understand how to present and manipulate data. For current customers, check out our .NET MAUI components on the License and Downloads page. If you are new to Syncfusion®, try our 30-day free trial to explore our .NET MAUI PDF Viewer and other .NET MAUI components. Please let us know in the following comments if you have any queries or require clarifications. You can also contact us through our support forums, support ticket or feedback portal. We are always happy to assist you!
In this article, you can learn how to create a .NET MAUI Tab View native-embedded Android application by following the step-by-step process explained as follows: Step 1: Create a .NET Android application and install the Syncfusion.Maui.TabView NuGet package. Step 2: In the project file of the native application, add <UseMaui>true</UseMaui> to enable .NET MAUI support, as demonstrated below. <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, a MauiContext object should be created. Converting .NET MAUI controls to native types will involve 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: Initialize the Tab View control. MauiContext? _mauiContext; protected override void OnCreate(Bundle? savedInstanceState) { ... SfTabView tabView = new SfTabView(); ListView listView = new ListView { RowHeight = 50, ItemsSource = new string[] { "James", "Richard", "Clara", "Michael", "Alex", "Clara" }, ItemTemplate = new DataTemplate(() => { var grid = new Grid { Margin = new Thickness(10, 5) }; var label = new Label { ... }; label.SetBinding(Label.TextProperty, "."); grid.Children.Add(label); return new ViewCell { View = grid }; }) }; Grid favoritesGrid = new Grid { }; favoritesGrid.Children.Add(listView); ... var tabItems = new TabItemCollection { new SfTabItem() { Header = "FAVOURITES", Content = favoritesGrid }, ... }; tabView.Items = tabItems; ... } Step 5: Convert the Tab View 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 mauiView = tabView.ToPlatform(_mauiContext); SetContentView(mauiView); } Output Download the complete sample from GitHub. Conclusion I hope you enjoyed learning how to integrate .NET MAUI Tab View with an Android native embedding application. You can refer to our .NET MAUI Tab View feature tour page to learn about its other groundbreaking feature representations. Explore our .NET MAUI Tab View documentation to understand how to present and manipulate data. You can check out our .NET MAUI components from the License and Downloads page for current customers. If you are new to Syncfusion®, try our 30-day free trial to check out our .NET MAUI Tab View and other .NET MAUI components. Please let us know in the comments section if you have any queries or require clarification. Contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!