3

I have a project requirement which requires android to be always powered on with service running in background. While I can handle service part, as from 2.2 by using START_STICKY, still there is no way I can guarantee the device always is on. Or at-least if connected to power-supply should boot automatically, if switched off.

Is there any solution for this in real world ? Except for going to make a new firmware, I need some ideas or a workaround. Thanks.

UPDATE: I thought to be better more clear. In my case I am not using android as a mobile and there will be no user. Its use is like an hardware equipment running android which once installed with my app, no one has access to it. And is always connected to power supply and internet. Also user will have access to its power-supply controls.

I agree it cannot be done from inside application or using Android APIs. But this is a real world problem, and I desperately need a solution on this. Any thing even not related to programming, may be mechanical or anything.

Pritam
  • 2,367
  • 5
  • 34
  • 50

5 Answers5

1

I also wanted to do the same but could not find any solution online. Then I came up with a hardware solution which I have described in my blog here http://iembed.tumblr.com/post/9055351385/boot-on-power

Hope this helps!

0

I found an app that allows you to boot your device when it is off and charging

The app called NoMoarPowah!

It can run on specific devices and requires rooting. You can boot your device if the battery charged or 15% charged or has enough juice to boot.

Try it...

yasserbn
  • 391
  • 3
  • 18
0

I doubt that there is a solution for your problem. The event of charging when turned off will never reach the top level but will be handled on low hardware level (turn on screen and display the charging status). So your application will never have a chance to react to such an event. The second thing is, that the user has always the power about the hardware. If he decide to turn off the device, it should and probably will turn off. The last chance he has is to remove the battery, off course.

So your solution is to reject this requirement because it can't be done.

WarrenFaith
  • 57,492
  • 25
  • 134
  • 150
  • Thanks WarrenFaith. In my case I am not using android as a mobile and there will be no user. Its use is like an hardware equipment running android which once installed with my software, no one has access to it. And is always connected to power supply and internet. – Pritam Feb 13 '11 at 14:20
  • 1
    If nobody has access to it, who's switching it off then? Who will plug in the charger if it is always connected to a power supply? Just wondering because it contradicts your initial statements... – sstn Feb 13 '11 at 14:22
  • 1
    So when nobody has access to the phone, it is nearly impossible to turn it off. So why worrying about that? – WarrenFaith Feb 13 '11 at 14:23
  • Its a hardware and something may go wrong, last week I have seen it turned off and had started to worry about the point. I had been assuming this till suddenly once I discovered it went off. Here's my question to find reason: http://stackoverflow.com/questions/4976523/does-android-mobile-has-any-error-log-file-to-debug-cause-for-auto-switch-off – Pritam Feb 13 '11 at 14:35
  • Ok, reboot or automatic turning off can be an issue, but the result is the same: no application can handle what you request. – WarrenFaith Feb 13 '11 at 14:38
  • @sstn I cannot detail more on project but we have access to power supply, and can toggle it. And ideally its not to be switched off anytime. – Pritam Feb 13 '11 at 14:39
  • @WarrenFaith Yes I understand that completely. So I had said anything .. some idea ... out of the box , some thing .. some way ... its a real world problem. – Pritam Feb 13 '11 at 14:42
  • Minimum requirement would be to modify the boot loader / low-level software to not go into charging-only mode, but to automatically boot the full system. Means you need to do some fairly low-level stuff. You still need a hardware watchdog to reboot your system if something goes terribly wrong (this might be integrated in the MCU) if you are concerned about reliability. – sstn Feb 13 '11 at 14:45
  • @sstn Thanks. So can somebody guide me for how should I go in acheiving this. I have a fair experience in application level but never had any hands in low-level stuff. Any quick ways or any help I can get from somewhere ? – Pritam Feb 13 '11 at 14:49
  • You need to have information on the hardware of your device - which is difficult to get through official channels for most consumer devices. Some experience in this area will definitely help. Maybe those people doing custom ROMs might be able to help. – sstn Feb 13 '11 at 15:25
0

I don't know what you want to do but this looks like a really bad idea... Anyone would immediately uninstall an app like this. If I turn off my phone I don't want to have an app which turns my phone on without asking me.

Anyway this looks impossible to do... The android API does not allow you to do it.

Dalmas
  • 26,409
  • 9
  • 67
  • 80
0
 PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
            mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK
                    | PowerManager.ACQUIRE_CAUSES_WAKEUP,
                   "Any String");
mWakeLock.acquire();
sandeep549
  • 496
  • 4
  • 6