I want to change the brightness, I can use this method:
public static void SetBright(int brightness, Context context) { if (isAutoBrightness(context)) { stopAutoBrightness(context); } WindowManager.LayoutParams lp = ((Activity) context).getWindow() .getAttributes(); lp.screenBrightness = Float.valueOf(brightness) * (1f / 255f); ((Activity) context).getWindow().setAttributes(lp); }
I need an operation to go to SetBright(int brightness, Context context);
But now I need to call the SetBright(int brightness, Context context)
method in Brocastreceiver. I can use the context in the onReceive method (context context, intent intention), but if I exit the application, it does not work.
Is there any other way that I can use to change brightness instead of using activity?
source share