4

Problem:-

I want to control the brightness of screen using a background service in android.

Existing Solutions:-

There are similar question posted in the form in below link:-

Adding screen brightness controls to android application

Why existing solution will not work?

All the solution provided in the link works well with an Activity, but I want to write a Background Service which controls the brightness of the screen.

So can you someone please help me find a solution on this issue.

Thanks in advance

Community
  • 1
  • 1
Naveen Murthy
  • 3,661
  • 2
  • 21
  • 22
  • Just so we can help give you a better answer, what would you like to achieve with doing this in a background service? Is it for a widget? – Anthony Forloney Feb 08 '10 at 14:30
  • no its not a widget. I want to switch on and off the screen light based on different application use. For eg:- if a phone call comes switch of the light in 4 sec. But this is activity dependent. I want a independent service which monitor different application and change the screen light. – Naveen Murthy Feb 08 '10 at 16:32

1 Answers1

2

From your service, start an activity and finish() it real fast!

MrSnowflake
  • 4,724
  • 3
  • 29
  • 32
  • Sorry for my later reply. I have tried to start the activity and close it in the oncreatre() method, but as I close the application all the changes I have made to modify the screen brightness has no effect. The solution to this problem is to create a transparent activity. Thanks for giving right direction. – Naveen Murthy Feb 15 '10 at 10:11
  • 1
    It doesn't work perfect. Because the activity to refresh will stay in task-list which names "recently" normally. In order to avoid this we must add two attributes on activity to refresh in the mainifast See here https://github.com/XinyueZ/brightnessdemo .... android:taskAffinity="com.schautup.brightness.REFRESH" android:excludeFromRecents="true" .... – TeeTracker Sep 22 '14 at 13:09