android - Best way to change a setting in activities from another one activity -


i'm creating simple ebook, need change screen brightness of activities main activity, receive data bluetooth , still running in background when book running. question is: how call function mainactivity page1activity, or reverse, whatever.

if put code in 1 of activities, can change activity brightness, need call 1 another

windowmanager.layoutparams lp = getwindow().getattributes(); lp.screenbrightness = adjusted; getwindow().setattributes(lp); 

if use one, pages displays changes when created, don't want recreate page whenever receive data.

android.provider.settings.system.putint(getcontentresolver(),         android.provider.settings.system.screen_brightness_mode,         android.provider.settings.system.screen_brightness_mode_manual);  android.provider.settings.system.putint(getcontentresolver(),         android.provider.settings.system.screen_brightness, (int)(255*adjusted)); 

then need know if there way or store activity use getwindow(), or if exists way call function between 2 activities or if there way that.

ps: know function change volume, if use in main activity, audio of whole system changed instantly, if know function use in brightness one, simple way solve problem.

audiomanager.setstreamvolume(audiomanager.stream_music,         voladjusted, audiomanager.flag_show_ui); 

at first add permission manifest file.

<uses-permission android:name="android.permission.write_settings"/> 

then can change brightness running following lines of code:

android.provider.settings.system.putint(getcontentresolver(),android.provider.settings.system.screen_brightness, brightness); 

note brightness must int value between 0 , 255.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -