Click here to Skip to main content
15,893,161 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi all,

I am developing a project which includes a windows form based application and a java android application. I need to pass data from the users inputs on the android application to the c# system on the computer. Can anyone guide me for a suitable method or tutorial?

I was looking into Google Cloud Messaging but I am not really sure how it works. I think that only the server can send messages.

Thanks
Posted
Comments
Sergey Alexandrovich Kryukov 5-Feb-15 14:25pm    
Are they on the same system? Which OS? :-)
—SA
developerjm 5-Feb-15 14:49pm    
Not the same system, I have a windows for application on Windows 8 and an android application on my Nexus 4.
Sergey Alexandrovich Kryukov 5-Feb-15 14:57pm    
Then you need networking interaction? What's the problem? Please describe what you want to achieve, exactly.
What have you tried so far?
Both Java and .NET have sockets, for example.
—SA
Afzaal Ahmad Zeeshan 5-Feb-15 15:09pm    
Correct, he would have to go deeper into networks, and would have to work around in ports and other network related fields. But creating a web service would be a good idea, that can be consumed through a/n (ASP.NET) website (in the Android app), that would be the client, and the WCF would act as a host. This would lessen down the pain of OP and would be helpfull. WCF service can be consumed by clients on .NET; which he is also having as by saying he is using a Windows Form application. Do see my answer too for if I am missing something. :)

Otherwise, if he has to work around in networks, he would surely be better served by C++, which might not be a good choice for him.
developerjm 5-Feb-15 15:11pm    
I have been trying with socket layers and I have succeeded but I need to know if there is a simpler way because I'm not sure how to pass the data because I have several stages where data needs to be passed. I want to the app to interact with the windows form to compare data from one end to another and if the data is the same, the system will proceed.

1 solution

You think in a very old way, sorry to say that. Because now adays even clients can send the data to the server, in many ways, one is an old way of HTTP requests, others include Ajax requests. But that is pretty much off-topic for your question. What you need is a network based platform, for interaction and communication between the Android application and a Windows 8 based Windows Form application. Although they're totally different, and would require something to be similar between them.

A simple way of doing this can be using a website, which you can surf to using the WebViewClient[^] view inside any Android application, or you can develop an application for the Android client and embed a WebViewClient, that would navigate to only your website. For example, at this Android developer document[^], it is shown a very basic example of creating a web app in Android. After that, you can push the data back to the Windows Forms.

Let us now think of a WebService. Take WCF, for example. You're having a .NET framework application, that is why using another .NET application won't cause you a fortune. Let's say you create a web service that can be consumed from other clients, through the network; a web service has an IP address to which clients connect and perform different actions, you can either use a network defined IP such as localhost (which would work on your own router) or you can purchase a stable IP address and set it to the web service for the clients to connect to. You can read this article[^] of mine, to create a simple WCF web service to be consumed by a website (or any other framework running over .NET framework as a client).

Once that has been taken care of, you can create a website, through which you will access the web service for posting the data to the web service (which will not act as a hub) and then you will push the data to the Win form, similarly if you're using the service through Win form, you can transfer the data to the Android application through that central hub of yours. So now the actual code would execute at the hub (web service) and which will push the data to the clients.

You can read this article, to get more in-depth knowledge of Broadcasting Events with a Duplex WCF Service[^]. Article is capable of explaining the methods used in sending the data from clients to clients using the same WCF central hub. One thing you should note is, that the client (website) and the host (WCF) are a part of applications that are running over .NET. As in comments to your question, if you want to create an application that would be using Java or any other framework you would have to leave .NET and would have to work for ports and networks (in low-level format) hopefully, C++ would be a great langauge for you then. Otherwise, .NET framework and Java both have a great API for working with networks and other ports, that you can use to directly connect your application to each other over the network without using any other medium between them. .NET framework network namespace[^], and the Java network related APIs[^], these both would be helpful for you if you want to continue this way.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900