Check File in the server is change or not - java

I am trying to make an app that connect to the server.
The app is used by some devices.
If one of the devices upload something to the server, I would like other devices receive the notification about the server has something new.
My question is, how to check the server is change or not? How often we must check the server?
I wonder how the Online Messaging work, because someone send something, we receive the message ASAP
Is the concept can be use with my app?

Sounds like you want to take advantage of Google Could Messaging or GCM for short.
http://developer.android.com/guide/google/gcm/index.html
This could be a lightweight message telling the Android application that there is new data to be fetched from the server (for instance, a movie uploaded by a friend), or it could be a message containing up to 4kb of payload data (so apps like instant messaging can consume the message directly).
GCM is the standard for how your apps "talk" to your servers. Either for a message in it's entirety or just a message to go check the server because it's been updated.

Related

GCM device to device messaging - how is it done?

I'm interested in how apps like WhatsApp implement this feature.
I've just read that it's bad practice to send the message directly from device to device, because someone can eventually get to the API key and send messages as my application.
What's the solution then? Having a server and making the devices only communicate with this server, so when I want to send a message to another device, it goes to the server and from server to that target device?
Also another question:
public void onMessageReceived(String from, Bundle data)
This is a method of the GcmListenerService. When is "from" different than the default senderID? Because I tried sending the message directly from one device to another and the "from" was still the default senderID that I got when I registered the app on the website.
Basically, you need a server to listen to upstream messages and broadcast then again to intended recipients.
You can find an article describing this here: http://javapapers.com/android/android-chat-with-google-gcm-xmpp/
The approach is pretty limited and not as flexible as having your own messaging server, but should be enough for a proof of concept.

Create a basic network app

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)

Send Identifiable SMS

I am writing an Android application that needs to communicate via sms. So for example application will send a message "Hi" to number 123, when number 123 receives the message it will be parsed on their phone by my application and acted on if it was determined to have been sent by my app.
Now I have the sending and receiving/parsing of messages working perfectly but I need a way to identify that the message was sent by my app. I could easily semd the message as "appName:hi" and check to see if the body contains 'appName' but the problem is if the user who receives my message doesn't have my app I would prefer if they just saw "Hi". So I was wondering if theres a way for example to send invisible characters or set some other identifying information either in the sms body or as part of the sms itself ie header. I would like to avoid data sms if possible and my app is intended to be offline.
Any ideas how I could accomplish this?
You can specify port when sending SMS. I do not know how to do this with Android API but since this feature has being supported for years by J2ME Android must support it too.
Your application should listen to this port and send to the same port. So, if user already has your application I think he even will not see the message in his inbox. At least this was the behavior in J2ME. If however he does not have the application yet he will either see it in inbox or will not see it at all. Check this with android. As far as I remember in J2ME it depends on the phone model.

Regarding automatic Push Notification

I am using the Google-GCM service for pushing notifications to a mobile device & building this application in Java EE.
I'm perfectly able to push notifications to the mobile device. And from the client-end (mobile) I'm able to receive input(string).
Henceforth my conceptual question starts: When I'm receiving input from a mobile (let's say: "Hello, Server"), I'm trying to build an automated process on the server-side and in reply it will push a notification (let's say: "Hi client, I'm fine; How are you?") automatically.
I want to grab some idea to push the notification automatically whenever the mobile device is registered. How do I do it?
All realistic implementations of GCM include a stage where an app receives a RegID, and communicates the RegID back to the server, typically via an HTTP service, typically along with some other business specific data. The server would store the RegID, associating it with other data, and later use it to send messages.
Have you implemented automated the delivery of the GCM registration ID to the server yet? If so, in the same piece of code, you might as well push a notification back. If not, do put together some. Server-side implementation would depend on your server's platform, naturally.

Open my mobile Java program with SMS, no SMS in inbox

Is it possible to open my mobile Java program with an SMS?
And I don't want this SMS to be stored in the inbox. I'm looking for the kind of "Control SMS" that banks use for their mobile applications. I want the same in my application: send SMS to the mobile, the mobile device shows a message on screen that will be opened by the program, and this SMS should not be saved in the inbox.
Are you sure that you're not mistaking push notifications/cloud to device messages for SMS's?
Push/C2D messages are similar to SMS's inasmuch as a central server sends a message out to devices and many apps then display a popup based on that message, but the implementation is completely different. If you're not mistaking the two, is there a reason you'd prefer to use SMS's that are handled differently than most instead of push/C2D messages?
Here's the documentation for Apple's Push Notification Service.
Here's Android's Cloud to Device Messaging documentation which serves the same purpose.
Have a look and see if that would serve your needs.
If you are looking for completely client side J2ME based solution for feature phones - then try push registry. It is available above MIDP2. I don't know the exact details but there you can define event and triggers which will be stored by phone OS and invoked automatically when particular type of event occurs.
SMS sending is separate issue but there are tools available for that definitely.

Categories

Resources