1

I want to develop a system in which data is being shared between DESKTOP app and Android app. After searching I have found that I need a server in between them. But I can't figure out what the server is? How do I create it? And how will it help me connect my two platform devices?

Desktop App will receive data from android app. And manage data. It will also be used to send notifications/messages to android apps.

Android App will be used to input data and send it to desktop app. It will receive updates/notifications from desktop app.

Now how do I connect these two? I basically need a common database for real-time data sharing and notifications.

Edit: I am building the desktop app using C# and android app using Java.

Edit2: Maybe I can host the database on CPANEL or 000webhost using PHP. And then connect it with both android and C#. Is this the correct way to do it? Is it possible to connect it with C#? I know it can be connected with Android, not sure about C#.

NiaziBro
  • 51
  • 1
  • 6
  • When you searched for "realtime database", what results came back? Hint: if you don't understand how to setup a database server, use a publicly available, hosted one – OneCricketeer Nov 29 '17 at 04:47
  • So I should use Firebase? And connect it with both desktop and android app? I am just confused. – NiaziBro Nov 29 '17 at 04:59
  • You can use notifications via some background threads, I don't know about C# clients, but you can check . If you want to run your own server, Rethinkdb or Couchbase have C# clients – OneCricketeer Nov 29 '17 at 05:12
  • In any case a LAMP service on 000webhost will work fine, but it certainly is not realtime – OneCricketeer Nov 29 '17 at 05:14
  • https://stackoverflow.com/questions/41676714/using-firebase-in-net – OneCricketeer Nov 29 '17 at 05:16
  • Another thing to keep in mind if you self-host, are you going to leave your database running forever and expose your home network to the internet? – OneCricketeer Nov 29 '17 at 05:17
  • @cricket_007 can you share any links which show how to connect and share data between android and desktop apps? – NiaziBro Dec 21 '17 at 08:03
  • "Desktop app" and Android should be connected to a shared remote database. They're not going to share data between themselves. Asking for tutorials is off topic for Stackoverflow – OneCricketeer Dec 21 '17 at 14:30
  • So how will I send commands, messages and locations between them? What if I want to inform Android app to go-to a location A and then when Android reached A it collects information and sends back that information to me(desktop). – NiaziBro Dec 22 '17 at 02:08
  • People have already been suggesting Firebase to you... You're looking a system that provides real time updates for free and no install efforts from you? That's the only option I know of. We've already established that Firebase has a REST interface for all non supported languages. If you want real-time notifications on top of this, you need to use a GCM or APNS server https://www.pubnub.com/blog/2015-01-20-mobile-push-notifications-101-apns-gcm-vs-pubsub-explained/ – OneCricketeer Dec 22 '17 at 03:31
  • Alternatively, go ahead, use a PHP website with a Mysql server. Your desktop app will constantly pull database information in an infinite loop for new information. And your Android app will send updates to the same database via a PHP REST API. (Although the web server can be written in any language if you don't know PHP) – OneCricketeer Dec 22 '17 at 03:33

2 Answers2

1

You don't necessarily need a database. You need a common network protocol between two applications.

All network communication is done via sockets. You need a library that allows you send data over sockets. For example, here's an Android guide that is about sockets.

A socket binds to a specific port of a computer, essentially making it a "server". Much like how web servers all expose port 80, and communicate over a protocol called HTTP. Which is important because it is up to you to decide what protocol your applications communicate between each other, because the socket just sends bytes - it doesn't care what you send or how, as long as it travels to a port on a particular server. It also won't parse the data for you, that's up to your application to handle. For example, how would your desktop app know the Android device sent it a text message, or some image to be displayed, or an address to show a map?

All in all, your reason for wanting a desktop application rather than a web application is not entirely clear. Parsing only the body of HTTP payloads from different HTTP paths that are mapped to different methods (which is typically referred to as a REST API) is much simpler than building your own protocol. You might as well build a desktop GUI over top of a web server.

Making the desktop app send updates back to your mobile application is basically impossible using a bi-directional socket architecture. Your Android should not be running an open server socket continuously just for your application, mostly because battery drain, but because its network address is subject to change frequently, and you therefore additionally need a registration server from which your device would reconnect to. Such a service exists as Firebase Cloud Messaging, which is a rebranding of the GCM technology made by Google, and it can be used to send push notifications to devices, but only with small data payloads.

See here about what activities occur on an Android device for notifications. How does push notification technology work on Android?

Back to the question about databases. Suggesting one to use is too broad. And you only need one of those if you want to store and/or query or join datasets. The same computer running the desktop app can install and run whatever flavor of database you prefer, whether it's a relational database or noSQL database, entirely up to you. The only realtime databases I know of are RethinkDB and Firebase.
You could also just hold a SQLite file which is as good as a small scale database (even the SQLite documentation recommends it for low traffic web sites).

OneCricketeer
  • 126,858
  • 14
  • 92
  • 185
0

Firebase supports web interface, so you can develop html code and integrate in desktop app, something like web integration in windows form application