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.
SAMSUNG and Cookies
Our site uses cookies, including optional cookies to provide you with the best experience on our website and relevant advertising based on your use of our site, You can manage your preferences or accept all cookies.
You can also read our Privacy Policy and Cookie Policy.
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
.samsungdeveloperconference.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
LinkedIn
.linkedin.com
Meta (formerly Facebook)
.samsungdeveloperconference.com
Google Inc.
.samsungdeveloperconference.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
LinkedIn
.ads.linkedin.com, .linkedin.com
Advertising Cookies
These cookies gather information about your browser habits. They remember that
you've visited our website and share this information with other organizations such
as advertisers.
Company
Domain
LinkedIn
.linkedin.com
Meta (formerly Facebook)
.samsungdeveloperconference.com
Google Inc.
.samsungdeveloperconference.com
Preferences Submitted
You have successfully updated your cookie preferences.