Languages

Menu
Sites
Language
Calling A Method from ServiceApp

I am using this tutorial for using a ServiceApp in Tizen Werable Application. Can I call a specific method from the application which launched the service ?

e.g. I have the following methods in my ServiceApp_App.cs file:

 

public void StartRecordingData()
{
    //Do Something
}

public void StopRecordingData()
{
    //Do Something
}

 

Can I call these methods by any means from the UI App (which launched the Service App) ?

I was thinking about using the AppControl object somehow, which I used to launch the Service. Any guidance will be highly appreciated :) 

View Selected Answer

Responses

2 Replies
Mark as answer
Tizen .NET

You can call your service app's methods from the UI app by using (custom) AppControl and send a reply via AppControl.ReplyToLaunchRequest()
// UI App
            AppControl appcontrol = new AppControl()
            {
                ApplicationId = "org.tizen.example.MyService",
                Operation = "http://tizen.org/appcontrol/operation/XXXX",
            };
            AppControl.SendLaunchRequest(appcontrol);

            AppControl appcontrol = new AppControl()
            {
                ApplicationId = "org.tizen.example.MyService",
                Operation = "http://tizen.org/appcontrol/operation/YYYY",
            };
            AppControl.SendLaunchRequest(appcontrol);


// Service App
        protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
        {

            base.OnAppControlReceived(e);

            if (string.Compare(e.ReceivedAppControl.Operation, "http://tizen.org/appcontrol/operation/XXXX") == 0)
            {
                call_your_service_xxxx_method();
            }
            else if (string.Compare(e.ReceivedAppControl.Operation, "http://tizen.org/appcontrol/operation/YYYY") == 0)
            {
                call_your_service_yyyy_method();
            }
        }


Plus, MessagePort, DataControl or RPC Port can be used if two apps want to communicate each other. In case of RPC Port, With TIDL code is generated for the interface defined by the developer and you can call it.

 

Itban Saeed

Thanks a lot for the response. Using the message ports, I'm able to call the method now whenever as per my requirements.