I create live time app ,and I check a link url every 5 second in activity and get string value for result
I check the result same as
If oldvalue <> newvalue do
Play a sound And Show "Alert" in notification area
How can I do that work in behind same as service ?
Neither you, nor your users will be happy with this solution.
Since you already have a server, at which you are checking, why don’t you implement Push mechanism, whenever there is a new event.
Simple, use Google Cloud Messaging for this, and it is a perfect solution.
You invoke the code for push, when the state changes, and it will alert the user. It can even popup a notification, play a sound, or invoke an activity too (if you want).
let me know if you want any help in implementing GCM.
Use the following links, they are very good.
http://developer.android.com/guide/google/gcm/gs.html
http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/
Cheers!