How to Package UI and Service Applications Together and Perform Them

Juwon Ahn

Create a new Tizen project for Xamarin.Forms application

  1. To create a new project, navigate to File > New > Project....
  2. Select any Tizen App template (except the Service App template) under the Visual C# selector (Tizen).
  3. Enter your project name, specify its location, and click OK.

Add a new project for Service application

  1. In Solution Explorer, right-click the solution node and click Add > New Project...
  2. Select the Service App template (Tizen) under the Visual C# selector.
  3. Enter the name of your Service application, and click OK.

Add a Service Application reference in Xamarin.Forms application

  1. In Solution Explorer, right-click on the project name of your UI application, and click Add > Reference.
  2. In the Reference Manager dialog box, select the project you want to reference, and click OK.

Build the entire solution

When you try to build the solution, you may see the following error message:

Project ServiceApp is not compatible with tizen50 (Tizen,Version=v5.0). Project ServiceApp supports: netcoreapp2.0(.NETCoreApp, Version=v2.0)

To resolve, you need to edit the project file (.csproj) of your service application to change the TargetFramework.

As Is




Note: This solution is based on Tizen 5.0. If your application is based on Tizen 4.0, change TargetFramework to tizen40 instead of tizen50.

After modification, go to Build > Rebuild Solution to rebuild all projects.

Launch the applications

Because the UI (Xamarin.Forms) application does not launch automatically, it must explicitly invoke your Service application. To do this, define the mandatory privilege for application launch in the tizen-manifest.xml file as follows:

The UI application can then launch the service application (application id: org.tizen.example.ServiceApp) by executing the following code:

AppControl appcontrol = new AppControl
                ApplicationId = "org.tizen.example.ServiceApp",
                Operation = AppControlOperations.Default,

            AppControl.SendLaunchRequest(appcontrol, (launchRequest, replyRequest, result) =>
                switch (result)
                    case AppControlReplyResult.Succeeded:
                        label.Text = "Service application is successfully launched.";
                        Console.WriteLine("Service application is successfully launched.");
                    case AppControlReplyResult.Failed:
                        label.Text = "Service application is not launched.";
                        Console.WriteLine("Service application is not launched.");
                    case AppControlReplyResult.AppStarted:
                        label.Text = "Service application is just started.";
                        Console.WriteLine("Service application is just started.");
                    case AppControlReplyResult.Canceled:
                        label.Text = "Service application is canceled.";
                        Console.WriteLine("Service application is canceled.");

Alternatively, the service application can respond to the launch request as follows:

        protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
            // Reply to a launch request
            ReceivedAppControl receivedAppControl = e.ReceivedAppControl;
            if (receivedAppControl.IsReplyRequest)
                AppControl replyRequest = new AppControl();
                receivedAppControl.ReplyToLaunchRequest(replyRequest, AppControlReplyResult.Succeeded);

You can get sample code from XamarinFormsAndServiceApps. The following message appears when you execute the code on a Tizen wearable emulator or a device: