I have installed apache web server on a Raspberry Pi. I made also an android application that connects to the server and post some requests successfully. The app "speaks" with an index.php file placed in the web server.
I installed a motion sensor on the Raspberry and I want the server to send data to the application if the motion sensor is triggered or not. Is there any way to do this or request the web server from the android app if the variable (e.x. motionstate) is "active"? If I need to provide more informations or parts of the code feel free to ask.
The easiest way would be to have a a code snippet running in your server which periodically(Google for Event Handlers in PHP or Polling/Looping) checks if the value of the variable (ex motionstate) has turned to active and then inform the app using an API call(or the other way around ie Android App fires a call periodically to server running in device to get data).
Refer to this for some idea: http://www.robertprice.co.uk/robblog/using-motion-sensor-raspberry-pi-php/
Related
I have a java web application running in my workplace.
I was asked to create a new application to "communicate" with network devices and read their statuses.
As an example I started working with a UPS, which is connected to my network with its own Network Interface Card.
I can monitor its status and details with its built-on platform entering with its IP address on a browser. But the idea is to add some of these details to the original web application.
To my understanding I can use a SNMP library for Java and create an application to get and set values to it. In my case i'm using the SNMP4j(V3) library, I imported it to Eclipse (IDE), but have no idea on how to continue from there really.
I'm looking to program a network application. I was going through: http://www.stanford.edu/class/ee368/Android/Tutorial-3-Server-Client-Communication-for-Android.pdf which talk about server and client programming for android. Now imagine I don't have an internet connection and I want both server and client applications run on either same android device or different android devices locally.
Is it possible to develop and run both server and client applications using TCPIP/UDP/Multicast locally on either standalone android device or multiple android device?
Yes, it is possible to communicate between Android devices or applications that are not connected to the Internet.
If you are using different devices, you probably want to use sockets, but it is possible to run an HTTP server on the server device and then use HTTP. Make sure they are connected to the same wifi network.
There are several different ways to communicate between different processes on the same Android device. The easiest might be to use a Messenger service but sockets and HTTP are also possible here.
Yes, it is possible in some manner.You can either use sqlite database present in android device to store various types of data in table form and data retreive from same.
Another way is to use Parse cloud as a server or backend of your client application.It allows your app to run even when you are not connected to internet.It stores the data in cache memory with its api and then uploads data to the server cloud as soon as you get connected to Intenet.
You can ask if you have any further queries. :)
I have a little question about an android app with a function "remote" use via internet.
So I have these ideas:
Create a webservice using php on the server, and refresh the client app all x time like 4-5 sec
Or make a java server (so I don't know how I can do that)
I just want make a remote connected via user/password to the server and the other app connect to the server and refresh his status.
Do you know the best way for do that?
Thanks
The question is not very precise, but as far as I understand it, both your ideas implement the 'pull' concept, that is the client app checking the status of the server every now and then.
If you want the app to be instantly notified of the server status change, I would suggest push notifications with GCM (Google Clound Messaging). You can find some basic descriptions and examples at: http://developer.android.com/google/gcm/index.html
Sending a server-to-client notification is simple regardless of the platform you use server side. E.g. for PHP integration with GCM, check out this thread: GCM with PHP (Google Cloud Messaging)
I want to write an application for Android, a card game that can be played both locally and online. That means we have clients (Android phones), and servers. Ideally, an Android phone should be able to be used as a server and host a game (and play it at the same time). I don't want to duplicate code between the server and the client.
Here is what I had in mind: having the application contain the server part, that would be runnable indepently by the application itself, or without the application (on a computer).
In a local game, a thread would be run for the server, and another one for the client (which communicates with the local server through localhost). In an online game, a distant server is running, and the local client communicates with it through the network.
My questions are:
Will my application be able to communicate with a thread that comes from itself, through localhost?
Can I have the entire application as the server? On the phone, it would run the server thread, then the client thread (do I need one?). On the distant server (desktop computer), I would run only the server thread, without all the Android stuff.
Do you have an other idea?
I hope I have been clear enough for you to understand the problem.
Thanking you in advance.
Yes, your app could communicate with itself through TCP sockets, that shouldn't be a problem. I'd advise you to take a look at putting most of the server functionality into a jar file, then you would have an Android APK and potentially a separate Java frontend for your desktop. You will likely need to have a little hosting code that's specific to each platform. It might make sense to put your server in an Android Service for example if you want to be able to host in the background.
I am now trying to do a project which is, there will be a server on windows pc and there are some clients on android devices.The point is the server one should control the android devices.For example it choose a image or video, send them to the clients and the clients play or show them.Remember the clients should be control by the server.
So could anyone tell me a proper way to do that, which protocol should i use, how do i send the files to the clients and how do the clients react? I am thinking of using java for the server and of course the client will use android application.
Thank you.
You might find Cloud to Device Messaging (c2dm) useful: http://code.google.com/android/c2dm/index.html
In essence, c2dm allows a remote server to send an Intent to an Android app. The device-side app can then respond to that intent to take the requested action. Chrome2phone works this way to open web links on a target device. http://code.google.com/p/chrometophone/