Skip to content

Commit 82e3820

Browse files
Merge pull request #1 from SyncfusionExamples/867184-AndroidNativeEmbedding_Scheduler
867184-Integrate .NET MAUI Scheduler with android native embedding application
2 parents 277f6b4 + aa65ea7 commit 82e3820

26 files changed

+216
-2
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.8.34408.163
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NativeEmbedding_Scheduler", "NativeEmbedding_Scheduler\NativeEmbedding_Scheduler.csproj", "{1D6B6F8C-0ACB-4BDF-9E96-A8B68684FA8F}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{1D6B6F8C-0ACB-4BDF-9E96-A8B68684FA8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{1D6B6F8C-0ACB-4BDF-9E96-A8B68684FA8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{1D6B6F8C-0ACB-4BDF-9E96-A8B68684FA8F}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
17+
{1D6B6F8C-0ACB-4BDF-9E96-A8B68684FA8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
18+
{1D6B6F8C-0ACB-4BDF-9E96-A8B68684FA8F}.Release|Any CPU.Build.0 = Release|Any CPU
19+
{1D6B6F8C-0ACB-4BDF-9E96-A8B68684FA8F}.Release|Any CPU.Deploy.0 = Release|Any CPU
20+
EndGlobalSection
21+
GlobalSection(SolutionProperties) = preSolution
22+
HideSolutionNode = FALSE
23+
EndGlobalSection
24+
GlobalSection(ExtensibilityGlobals) = postSolution
25+
SolutionGuid = {D5B82CF7-B31C-4158-8A87-D90B0BBCBDDB}
26+
EndGlobalSection
27+
EndGlobal
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:label="@string/app_name" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true">
4+
</application>
5+
<uses-permission android:name="android.permission.INTERNET" />
6+
</manifest>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using Microsoft.Maui.Embedding;
2+
using Android.App;
3+
using Android.OS;
4+
using Microsoft.Maui.Platform;
5+
using Syncfusion.Maui.Core.Hosting;
6+
using Syncfusion.Maui.Scheduler;
7+
using System.Collections.ObjectModel;
8+
9+
namespace NativeEmbedding_Scheduler
10+
{
11+
[Activity(Label = "@string/app_name", MainLauncher = true)]
12+
public class MainActivity : Activity
13+
{
14+
MauiContext? _mauiContext;
15+
protected override void OnCreate(Bundle? savedInstanceState)
16+
{
17+
base.OnCreate(savedInstanceState);
18+
19+
MauiAppBuilder builder = MauiApp.CreateBuilder();
20+
builder.UseMauiEmbedding<Microsoft.Maui.Controls.Application>();
21+
builder.ConfigureSyncfusionCore();
22+
MauiApp mauiApp = builder.Build();
23+
_mauiContext = new MauiContext(mauiApp.Services, this);
24+
25+
SfScheduler scheduler = new SfScheduler();
26+
scheduler.View = SchedulerView.Week;
27+
var appointment = new ObservableCollection<SchedulerAppointment>();
28+
29+
//Adding scheduler appointment in the schedule appointment collection.
30+
appointment.Add(new SchedulerAppointment()
31+
{
32+
StartTime = DateTime.Today.AddHours(13),
33+
EndTime = DateTime.Today.AddHours(15),
34+
Subject = "Client Meeting",
35+
});
36+
37+
//Adding the scheduler appointment collection to the AppointmentsSource of .NET MAUI Scheduler.
38+
scheduler.AppointmentsSource = appointment;
39+
Android.Views.View view = scheduler.ToPlatform(_mauiContext);
40+
41+
// Set our view from the "main" layout resource
42+
SetContentView(view);
43+
}
44+
}
45+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net8.0-android</TargetFramework>
4+
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
5+
<OutputType>Exe</OutputType>
6+
<Nullable>enable</Nullable>
7+
<UseMaui>true</UseMaui>
8+
<ImplicitUsings>enable</ImplicitUsings>
9+
<ApplicationId>com.companyname.NativeEmbedding_Scheduler</ApplicationId>
10+
<ApplicationVersion>1</ApplicationVersion>
11+
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
12+
</PropertyGroup>
13+
<ItemGroup>
14+
<PackageReference Include="Syncfusion.Maui.Scheduler" Version="*" />
15+
</ItemGroup>
16+
</Project>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Images, layout descriptions, binary blobs and string dictionaries can be included
2+
in your application as resource files. Various Android APIs are designed to
3+
operate on the resource IDs instead of dealing with images, strings or binary blobs
4+
directly.
5+
6+
For example, a sample Android app that contains a user interface layout (main.xml),
7+
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
8+
would keep its resources in the "Resources" directory of the application:
9+
10+
Resources/
11+
drawable/
12+
icon.png
13+
14+
layout/
15+
main.xml
16+
17+
values/
18+
strings.xml
19+
20+
In order to get the build system to recognize Android resources, set the build action to
21+
"AndroidResource". The native Android APIs do not operate directly with filenames, but
22+
instead operate on resource IDs. When you compile an Android application that uses resources,
23+
the build system will package the resources for distribution and generate a class called "Resource"
24+
(this is an Android convention) that contains the tokens for each one of the resources
25+
included. For example, for the above Resources layout, this is what the Resource class would expose:
26+
27+
public class Resource {
28+
public class Drawable {
29+
public const int icon = 0x123;
30+
}
31+
32+
public class Layout {
33+
public const int main = 0x456;
34+
}
35+
36+
public class Strings {
37+
public const int first_string = 0xabc;
38+
public const int second_string = 0xbcd;
39+
}
40+
}
41+
42+
You would then use Resource.Drawable.icon to reference the drawable/icon.png file, or
43+
Resource.Layout.main to reference the layout/main.xml file, or Resource.Strings.first_string
44+
to reference the first string in the dictionary file values/strings.xml.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent">
7+
<TextView
8+
android:layout_width="wrap_content"
9+
android:layout_height="wrap_content"
10+
android:layout_centerInParent="true"
11+
android:text="@string/app_text"
12+
/>
13+
</RelativeLayout>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
2+
<background android:drawable="@mipmap/appicon_background" />
3+
<foreground android:drawable="@mipmap/appicon_foreground" />
4+
</adaptive-icon>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
2+
<background android:drawable="@mipmap/appicon_background" />
3+
<foreground android:drawable="@mipmap/appicon_foreground" />
4+
</adaptive-icon>
2.13 KB
Loading
97 Bytes
Loading

0 commit comments

Comments
 (0)