I recently started Android coding and wanted to create a little program for changing the screen brightness... Well.. i know there are already some questions about it, but i tried everything suggested here and really dunno how i can solve my problem :) I understood that you have to "refresh" the screen after setting brightness. And at this point my problem starts... I've created some kind of dummy activity and also have an intent in my main activity, but it seems like the intent dont sart the dummy activity... Heres the relevant part of my main activity:
button1.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Settings.System.putInt(getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS, 255);
Intent in = new Intent(Test.this,DummyBrightnessActivity.class); //it is working...
startActivity(in); //it is working...
}
and the dummy code:
public class DummyBrightnessActivity extends Activity{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
this.finish();
}
}
the manifest.xml:
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".Test"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.Test.DummyBrightnessActivity"
android:taskAffinity="com.Test.Dummy"
android:excludeFromRecents="true"
android:theme="@style/EmptyActivity"></activity>
</application>
maybe relevant, the styles.xml:
<resources>
<style name="EmptyActivity" parent="android:Theme.Dialog">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Toast</item>
<item name="android:background">#00000000</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:colorForeground">#000</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:windowIsFloating">true</item>
</style>
</resources>
oh, btw... I dont get any errors... The dummy just wont start (I think so, because when i run it without android:excludeFromRecents="true" then it wont appear in the recent apps list.
I hope someone can help me... Have a nice day
//EDIT: Well... it looks like the code is working properly xD Just relooked and put some text instead of the "finish()" and the activity run properly... but i thought that the finish have to be there :/ Maybe you have any suggestions how to "reset" the screen instead? Looks like i understood one of the tutorials wrong...
//EDIT2: Well... I cant post an answer to my own question in the first 8hours:D So i post it in here:
Thank you all for the help and tips, but now i found the solution for myself :D this one: Refreshing the display from a widget? the part "kicking off an empty activity and executing the WindowManager refresh" is working for me. i came across this before asking here, but back then i just couldnt get it to work :D So, anyways, thank you very much ;) This was just an example of hard it can be to code "a little, fast-coded beginner app" ;)