0

I am writing an application for android that will use opportunistic communication. So when two devices are nearby they exchange data. For now it will happen when they are in the same wifi network (using mdns) or when they have paired bluetooth interfaces.

I was wondering from power manager point of view. Will my ongoing service be paused when phone enters sleep mode? If yes how do I prevent it?

Also any general tips how to make it consume as little power as possible? I was thinking to wake it up from time to time, but then there's a chance that it will miss a mdns query sent by other device which I want to avoid to maximize throughput.

And just to clarify - yes, I do want to use opportunistic communication and no I do not want to use any solution that involves connecting to the internet.

Any help appreciated.

siemanko
  • 1,389
  • 1
  • 13
  • 26
  • Look at this [Question](http://stackoverflow.com/questions/3723634/how-do-i-prevent-an-android-device-from-going-to-sleep-programmatically) – Bishan Jan 04 '13 at 11:01

1 Answers1

2

Use Wakelock to indicate that your application needs to have the device stay on. but it consumes considerable amount of power. you can also use AlarmManager to start your app at that particular time when wifi is available

Payal
  • 903
  • 1
  • 9
  • 28
  • I know I can use wake lock, but yes, I want to avoid consuming a lot of power. Ideally I would like to wake up when mdns multicast frame arrives. Is something like this possible? – siemanko Jan 04 '13 at 11:11
  • yeah sure ,in that case use alarmManager that can be used in two ways, as -To start some action, if a particular event happens, -To do some particular actions in every time interval. As specified in Android developer site, we will use AlarmManager, when we need to do some actions, even if our application is not running – Payal Jan 04 '13 at 11:20
  • OK, but I cannot see anywhere in AlarmService doc page an option to wake me up when multicast frame arrives. – siemanko Jan 04 '13 at 11:39
  • OK, I think I got it. This discussion suggests that my service will be automatically wake up on incoming packet ;-) https://groups.google.com/forum/?fromgroups=#!topic/android-platform/xTU1UeckGcM – siemanko Jan 04 '13 at 11:52