DISTRIBUTION OF TIZEN-BASED WATCH APPS HAS BEEN DISCONTINUED
Interact with the Application on the Android Device
1. Create a service connection.
Connecting to the first available peer found:
try {
var agent = await Samsung.Sap.Agent.GetAgent(Samsung.Sap.Service.Profiles.First());
var peers = await agent.FindPeers(null);
if (peers.Count() == 0)
{
Console.WriteLine("There are no peers to connect to.");
}
else
{
var peer = peers.First();
await peer.Connection.Open();
peer.Connection.Send(agent.Channels.First().Value, System.Text.Encoding.ASCII.GetBytes("Hello"));
}
} except (Exception exc) {
Console.WriteLine("Communication failure: " + exc.Message);
}
Handling of an incomming connection:
Samsung.Sap.Agent agent = null;
agent = await Samsung.Sap.Agent.GetAgent("/my/profile", onConnect: con =>
{
if (con.Peer.ProfileVersion == agent.ProfileVersion)
{
con.DataReceived += (s, e) => {
Console.WriteLine($"Received {e.Data.Length} bytes from {e.Peer.DeviceName}/{e.Channel.ID}");
};
return true; // accept connection from peers with the same profile version as ours
}
else
{
return false; // reject other connections
}
});
2. Disconnect the service.
Connection between Peers can be closed by calling Connection.Close() method.
connection.Close();
3. Send a message.
In this sample text message is sent using Peer.SendMessage(). In contrast to sending data using Connection.Send() method establishing connection between Peers is not required.
In this case, app replies to a receiving command from remote Accessory Peer Agent in Smart device by providing the current time stamp.
Manage Your Cookies
We use cookies to improve your experience on our website and to show you relevant
advertising. Manage you settings for our cookies below.
Essential Cookies
These cookies are essential as they enable you to move around the website. This
category cannot be disabled.
Company
Domain
Samsung Electronics
developer.samsung.com, .samsung.com
Analytical/Performance Cookies
These cookies collect information about how you use our website. for example which
pages you visit most often. All information these cookies collect is used to improve
how the website works.
Company
Domain
Samsung Electronics
.samsung.com
Functionality Cookies
These cookies allow our website to remember choices you make (such as your user name, language or the region your are in) and
tailor the website to provide enhanced features and content for you.
Company
Domain
Samsung Electronics
developer.samsung.com, google.account.samsung.com
Preferences Submitted
You have successfully updated your cookie preferences.