How to create companion app in Android? where is Accessory SDK?

When I see the samples here

Wearable sample is with .net c# but android samples are in Java. Is there any good sample with c#?

my question is should we handle peer connection in Android project or it is possible to do it net.standard project as well if my android application is xamarin.forms based? 

Another way of asking:

this article describes as if we can implement it in shared project but isnt recognized if i install from

And this article implement on Android project level


Which one should we follow?

Edited by: Emil Alipiev on 30 Jul, 2019


14 Replies
Tizen .NET


Java API is only available for Android.

  • Android Samsung Accessory SDK 2.6.1 API Reference

Emil Alipiev

Hi, It means that SAP is only for tizen watch application? it cannot be used with Xamarin.Android app? If that is the case only solution here is to use jar binding directly in project. I wish that you create a nuget package out of this jar library. it will increase usability of tizen with xamarin. thank you.

Tizen .NET

SAP API is available for Samsung Watch app(Tizen app) and Android Java app.

Emil Alipiev

Thank you for the answer. Let me ask you something. I have integrated SAP on my Samsung Watch App(Tizen) and now i want to integrate Companion app on my Android device. I went through the all your documentations and i am a little confused. Do I understand correct that I have 2 ways of integrating it on my Android Device?
- using Accessory SDK

- using SAP

What is the exact different choosing one over another?
Does SAP require to establish connection between watch and phone using 
 Galaxy Wearable  app and Accessory SDK doesnt? because i can do connection directly with my programming code if i use Accessory SDK. is that the only difference? 
Thanks for clearing that for me.

Tizen .NET

I'm so sorry if I make you confused.

You use Samsung Accessory Protocol (SAP) API  for Samsung Galaxy Watch apps to make a connection with android phone and send/receive data

and use Samsung Accessory SDK API for Android smart phone apps to do same.

Emil Alipiev

I am trying to create companion xamarin.forms app using android binding library with accessorysdk.jar. So far all seems fine but I am getting an exception on Socket class. it throws exception that Java.Lang.RuntimeException: Invalid implemetation of SASocket. Provider a public default constructor in the implementation class.

your sample helloaccesory phone apps are written in java and I converted one to one to c# and tried to implement it using dependecy injection on xamarin.forms app. I attach you the very small sample app. if you have time, could you please check my error? I appreciate your help

Tizen .NET

Samsung.Sap package can be used only for Tizen watch application(C#).

The following should be removed. (WearCompanion.Android.csproj)

    <PackageReference Include="Samsung.Sap">


Emil Alipiev

yes I already remove it in another attempt but that's not the main problem as you can see i am using accessory SDK  which i created using android binding library from jar and program complains about sasocket constructor. If you run the application in android and click send button you will see that

Tizen .NET

We cannot test your app because there's no dll file(myAndroidBindings.dll).

Please share it with us. (you can send it to

Emil Alipiev

ops sorry for that. i have reuploaded this project including dll inside the project folder. please download from this link

even if it helps here is the source code of binding dll project also

Tizen .NET

After modifying as follows, the error doesn't occur.

public static readonly Java.Lang.Class SASOCKET_CLASS = Java.Lang.Class.FromType(typeof(ProviderServiceSocket)).Class;

Plus, "accessoryservices.xml" file seems to be located in /res directory. Please put accessoryservices.xml file in res/xml directory and update the path in AndroidManifest.xml.

If not, the following error will occur.

 I [SA_SDK]ServiceXmlReader: Service description(s) file Location:/Resources/xml/accessoryservices.xml
 E [SA_SDK]RegisterUponInstallReceiver: Service Registration has failed!
 E [SA_SDK]RegisterUponInstallReceiver: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Accssory Service profile xml must be in /res or /assets directory.
 E [SA_SDK]RegisterUponInstallReceiver:   at
 E [SA_SDK]RegisterUponInstallReceiver:   at java.util.concurrent.FutureTask.get(
 E [SA_SDK]RegisterUponInstallReceiver:   at$ Source:2)
 E [SA_SDK]RegisterUponInstallReceiver: Caused by: java.lang.RuntimeException: Accssory Service profile xml must be in /res or /assets directory.
 E [SA_SDK]RegisterUponInstallReceiver:   at Source:369)
 E [SA_SDK]RegisterUponInstallReceiver:   at$a.a(Unknown Source:23)
 E [SA_SDK]RegisterUponInstallReceiver:   at$ Source:0)
 E [SA_SDK]RegisterUponInstallReceiver:   at
 E [SA_SDK]RegisterUponInstallReceiver:   at


Emil Alipiev

This solved the error and takes for the correction with XML file. One thing I dont understand here.

Saagent inherits from service. Normally in android applications we use startservice command to start a service but when I 

Examine your java sample for provider,  I dont see this anywhere. How does saagent service starts? Can we start it on demand?

Tizen .NET

I heard that SAAgent class extends Android Service and it binds to framework when it creates. It's unnecessary to call startservice.

If you want to get more techinal supports, you better ask details through Samsung Technical Support

Go to site  >> My Page (in the top right of the site) >> My Dashboard >> My Support Requests 



Emil Alipiev
Thank you for your Answer. I could almost established a connexion. Make a request from watch to Phone, I'm getting an error message that says it cannot find providerservice class which extends saagent. I have tried it were possible combination with and without namespace but no success. It seems that java path is different than xamarin path. If you look at my sample app, can you tell me which path should I use in accessory.xml file as serviceimpl path?