Blog


  • Blogs.net
  • Intercommunication between Windows and Android devices

Intercommunication between Windows and Android devices

By Aspire Softserv 30 Nov 2020

Intercommunication-between-Windows-and-Android-devices.jpg

Abstract:

To Implement the communication bridge between windows form application (running as a server) and android application (running as a client) running on the local network.

Enter Messaging Framework:

In this Blog, we are showing that how Eneter Messaging Framework is working and how we can use this to communicate.

  1. Eneter Messaging Framework is a lightweight framework for interprocess communication.
  2. It is easy to use and it works across various platforms.
  3. The framework provides communication components that you can use to create various communication scenarios.
  4. Below Graph shows the Communication between Android and Windows Application using Eneter Messaging Framework.
android-dotnet

To establish Connection between two applications, the Eneter Messaging Framework is use several protocols and Transportation mechanisms Like TCP, HTTP, UDP, WebSocket etc.

Types of Sending-Receiving Messages:

  1. String Messages
  2. Typed Messages
  3. Remote Procedure Calls.

Features:

Reliability:

The communication must be promising and Reliable. It Provides Monitoring of connection availability, Buffered messaging and automatic reconnect.

Security:

Communication across the network is easy to observe and confidential data can be acquired by Unauthorized Persons. Therefore, you may have to protect your data by using Authenticated connection, Encrypted Messages, and SSL.

Steps to establish the communication between Windows Form and Android Application using TCP

Create a simple Window Application in C# and Android application in Xamarin which is able to send and receive a message as shown in below images And Install Eneter Messaging framework library to both applications using Manage NuGet Packages.

step1
step2
step3

Step 1: In the code page of windows form in which you are designing, create properties to Send/Receive Messages and then, Create Object of Receiver. Sender-Receiver Request/Response Can be of any type like String, integer, Boolean, Class. Here, we are Creating Request-Response Class and declare Message Property in it.

Step 2: To Implement a Communication, need to create a service on the server. Service includes the creation of Receiver object, input channel and attachment of the input channel to the receiver. To Create and Start a service on a local machine which is acting as a server please follow the below steps:

  1. Create Message Receiver and Subscribe Handler to Handle Message and Then, Create Input channel to Receive the Messages from the client and Send response Messages to the client.
  2. The server is receiving the message from the client as well as send the response messages to the client. Clients which want to communicate with windows application are needed to be connected to the server. More than one client can connect to the server at a time.

Step 3: Implement the Event Handler, which is automatically called whenever the messages are received. It accepts the request messages and gives a response to that messages. We can see the Receive messages of the client in “Message Received from Client” List.

TCP Connection in Android Application:

When you implement communication via TCP on Android devices. There are two things that you have to care about which is mentioned as below.

  1. INTERNET Permission must be set on Android Application.
  2. You can’t set 127.0.0.1 (loopback) IP Address on Android emulator to communicate with the DotNet Application.
tcp-connection

Step 1: The Sender and Receiver must be having the same type and format. In the MainActivity.cs file, Create Request and Response Classes and declare message property into it. Create a Sender which used to send the Request message of a Request message type. 

Step 2: To Create Connection to the Server in which service is running please follow the below steps:

  1. Create Message Sender and Subscribe Handler to Handle Message and Then, Create and Attach Output channel to the Server IP Address and Port number. 

Step 3:  After connecting to the server, We Can Send the Request message to the server which is displayed in “Message Received from Clients” List at Windows Application. Then, Server sends the Response message to the client after receiving the Request message from the client. 

Step 4: Implement Handler to Handle the Response Message sent by Server. The client is received the Response Message using the output channel. The subscribe handler is automatically executed when it receives a message from the server and it displays the message in the “Response message” box. 

step3
step4

Conclusion

In today's interconnected world, the ability to seamlessly communicate between different devices is essential. The intercommunication between Windows and Android devices has become increasingly important as both operating systems dominate their respective platforms. Fortunately, several methods and technologies allow for effortless connectivity and data exchange between these two ecosystems.


Share Blog

Comments

Leave a message...

+

YEARS EXPERIENCE

+

CLIENT TELE ACROSS THE GLOBE

+

OVERALL PROJECTS

+

YEARS OF PARTNERSHIP LENGTH

+

Countries served

Subscribe to newsletter

I would like to subscribe to your newsletter to stay up-to-date with your latest news , promotions and events

Reach Out Image

REACH OUT

Ready to Build Something Great ?

Experience. Expertise. Know-How
80+

Tech Experts

13+

Years Of Developing

90%

Referral Business

Trust. Reputation. Standards
Aspire Softserv
Aspire Softserv
Aspire Softserv
Aspire Softserv
Aspire Softserv
Phone
mail-image
mail-image
mail-image