언어 설정

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

When I see the samples here https://developer.samsung.com/galaxy-watch/develop/samples/companion/hello-net

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 samsung.sap isnt recognized if i install from nuget.org https://developer.samsung.com/galaxy-watch/develop/creating-your-first-app/net-companion/interact

And this article implement on Android project level

https://developer.samsung.com/galaxy-watch/develop/creating-your-first-app/net-companion/use-accessory

 

Which one should we follow?

Edited by: Emil Alipiev on 30 7월, 2019

Responses

14 댓글
Tizen .NET

Hi,

Java API is only available for Android.

  • Android Samsung Accessory SDK 2.6.1 API Reference

   https://img-developer.samsung.com/onlinedocs/sms/accessory/index.html
   https://developer.samsung.com/galaxy-watch/develop/tech-doc/how-to-use-samsung-accessory-sdk

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 xamarin.android 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

https://drive.google.com/open?id=156xrll1Ha-k1Z2WR7v6sxy_3xnbYvQlW

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">
      <Version>1.0.0</Version>
    </PackageReference>

 

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 tizen.dotnet@samsung.com)

Emil Alipiev

ops sorry for that. i have reuploaded this project including dll inside the project folder. please download from this link https://drive.google.com/open?id=1iZ1BBRHQHe60H4urNEykCpF5hal_Ox2o

even if it helps here is the source code of binding dll project also https://drive.google.com/open?id=195oU1i0WlagwOOVBLg788Ku7cvDgC3Wp

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 java.util.concurrent.FutureTask.report(FutureTask.java:123)
 E [SA_SDK]RegisterUponInstallReceiver:   at java.util.concurrent.FutureTask.get(FutureTask.java:193)
 E [SA_SDK]RegisterUponInstallReceiver:   at com.samsung.android.sdk.accessory.RegisterUponInstallReceiver$1.run(Unknown 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 com.samsung.android.sdk.accessory.n.a(Unknown Source:369)
 E [SA_SDK]RegisterUponInstallReceiver:   at com.samsung.android.sdk.accessory.j$a.a(Unknown Source:23)
 E [SA_SDK]RegisterUponInstallReceiver:   at com.samsung.android.sdk.accessory.j$a.call(Unknown Source:0)
 E [SA_SDK]RegisterUponInstallReceiver:   at java.util.concurrent.FutureTask.run(FutureTask.java:266)
 E [SA_SDK]RegisterUponInstallReceiver:   at java.lang.Thread.run(Thread.java:764)

 

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 developer.samsung.com site  >> My Page (in the top right of the site) >> My Dashboard >> My Support Requests 

Thanks.

 

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?