0

Suppose I have a simple android app and have a function display() which will display simple "Hello World" message.

I also have a PHP script on server which have a simple button "Display", Now by clicking on this button I want to execute the display() function on android app.

I am new to android and don't know how to do this, someone please help.

Darpan
  • 33
  • 5
  • Welcome to StackOverflow. Possibly you are getting ahead of yourself in this app. Being new to android, you may want to start with simpler examples and learning more about how to do things like this, which tutorials exist for. Also, tell us what you have tried so we see some effort on your side. – erdekhayser Feb 11 '14 at 03:07

1 Answers1

1

You can use GCM Push Notifications service to send a push notification to a particular user. You can send it from your server to the device. Service runs in background always. The app can receive your message inside the GCMService. Then from within the service you can open any activity of the app. From the service you can choose use LocalBroadCastManager to send a local broadcast, which will be received by the activity which has registered for that LocalBroadcast. LocalBroadcast sends a broadcast within your app only. Then from there you can execute any function within that activity. There might be other ways but this is what comes to me instantaneously.

Checkout: how to use LocalBroadcastManager?

Hope this helps.

Community
  • 1
  • 1
Shobhit Puri
  • 25,769
  • 11
  • 95
  • 124
  • can you give me a simple example for that – Darpan Feb 09 '14 at 08:12
  • I think if you read each of the links mentioned. It will give you the overall picture. First you'll have to learn how to use GCM. Then How to use LocalBroadCastManager. Combining those will help youi implement the above. Check out the links and they should have examples. – Shobhit Puri Feb 09 '14 at 08:15