Android Development: Changing Screen Brightness in Service

后端 未结 2 615

Now i do try again.

I want to change the screen brightness.

I\'ve Tried:

WindowManager.LayoutParams layoutParams = getWindow().getAttributes(         


        
2条回答
  •  死守一世寂寞
    2021-01-14 03:22

    You would need to start an activity from your service, all you need to do is this:

    Intent myIntent = new Intent(getBaseContext(), MyActivity.class);
    getApplication().startActivity(myIntent);
    

    where MyActivity is the activity which you want to start. Inside that activity you can put code to change the window brightness, it will work.

    I've included the complete code here: https://stackoverflow.com/a/9848456/1204377

    Let me know if it's still unclear.

提交回复
热议问题