0

I've been reading lots of post but no luck. What I want is a similar behaviour to NoLed application, when the screen turns off i want to reenable it and show a low consumption screen. If the screen turs off when my aplication is in the foreground (visible to the user) everything goes OK, but if I press the home button and lock the phone or wait till the screen turns off, my low consumption screen won't be visible and the behaviour won't be the spected one. I've trying with this code, and all the possible flags mixed, alone... but no luck:

Intent i=new Intent(Este,BajoConsumo.class);
i.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
//i.addFlags(...);
startActivity(i);
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
user1368116
  • 121
  • 6
  • by screen black I assume you mean screen off. You'dd have to register a broadcast receiver – Blundell May 01 '12 at 16:23
  • Yes, by black screen i mean screen off. I have a broadcast receiver registered, the problem is to make the low consumption screen visible when screen turns off and the user is using another app or has pressed home button. – user1368116 May 01 '12 at 16:53
  • Make a notification in the notifications bar – Blundell May 01 '12 at 16:55
  • Yep. How would you like it if an invasive app overtook your homescreen and wouldn't let you do anything else. Thats why notifications are best practice, it's up to the user if they want to interact with your app – Blundell May 01 '12 at 17:09
  • Have you used NoLED? It's not invasive app, when the screen turns off and you have a lost call then the screen is turned on (because you have configured the app to do so) and shows you that there is a lost call for example. – user1368116 May 01 '12 at 17:40

1 Answers1

1

After some research I have found that the way to do this is to call;

Intent i=new Intent(this, BajoConsumo.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);

from a service, that will open and focus the new activity, and it will become visible.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
user1368116
  • 121
  • 6