0

I am developing an android application. What i want is to call a method present in that android application remotely from a desktop like from a "servlet" or an application.

How can this be done?? For example i want to call a method which i have already written in the app which calls a particular number. How can i invoke this method remotely?? please help.

PS - It is kind of urgent.

zoozo
  • 253
  • 1
  • 2
  • 10

2 Answers2

0

It will be hard to communicate from your desktop to your handheld. But you can poll a server from your handheld.

Write an app that every n seconds (the frequency you require) polls e.g. a web page on your server. When the web site's content is "noop", the app does nothing and keeps on polling. If the web site's content is "doit", the app dials the number you want.

So, when you change the content of this web page either manually or programmatically you can "remote-control" your hand held.

This is just an example, it must not be HTTP, neither NOOP and DOIT, just anything you like. Let the server return the phone number which you want dialled for instance.

Hyperboreus
  • 31,997
  • 9
  • 47
  • 87
  • Thankx for your quick response. I am trying to develop a device management app. I want to retrieve some data periodically like the GPS data which could be done by the way you specified but could other functions like remote wipe or remote lock be implemented?? – zoozo May 26 '11 at 04:30
  • Anything you want. Poll server. If server says "lock", call your local lock function. If the server says "wipe", call your local wipe function. Start your polling up on boot and you are set. – Hyperboreus May 26 '11 at 04:31
  • I really dont know that polling is as i have never worked on it. I know its kind of pinging. It would be really helpful if you could please elaborate or share some links. – zoozo May 26 '11 at 04:37
0

Well, sounds like you want your app to be waiting for push notifications. I think this question is exactly what you need to look at.

Community
  • 1
  • 1
Robert Massaioli
  • 13,379
  • 7
  • 57
  • 73
  • Robert i am trying to develop a device management app. I want to implement certain features like remote wipe and remote lock. I want to do it through a web interface. For example if i click on a button on a webpage, the device should lock immediately prompting for a password. How could this be done?please help. Thanks for the link, I am looking through it. – zoozo May 26 '11 at 04:33
  • I really don't have the time to help explain how to essentially write the whole project for you but I do suspect a few things. Firstly the app is going to need root otherwise the person that handles the device can just ignore any popup your app produces. Not only that but you will want to make it a service that runs in the background or just follow the advice in the link I gave. And that is all, it should just be a matter of using the Cloud To Device Messaging API to alert your root enabled app and lock the phone. – Robert Massaioli May 26 '11 at 04:48
  • c2dm api is what i am looking at now. There is no need to root the phone to execute these methods. The permissions will handle and no user confirmation is needed. Look at hyper's answer below. I will try making it a service and poll a server and will also try implementing the c2dm apis. Thank You Robert :) – zoozo May 26 '11 at 04:55
  • c2dm is obviously not what will require user permissions. It is locking the phone in such a way that the user cannot circumvent it that will require root. – Robert Massaioli May 26 '11 at 05:12
  • That is the thing behind android's dm APIs. User installs the dm app and agrees to the policies. After that wiping or locking doesn't require user permission – zoozo May 26 '11 at 05:31
  • @zoozo: Are you sure? Where did you read that because I thought that the permissions just gave it access to handle the push notifications? – Robert Massaioli May 26 '11 at 05:57
  • Check out the android.app.admin package's documentation on developer.android.com. It doesn't require user permission but the user has to agree to the policies however. – zoozo May 27 '11 at 06:17