我最近開始的Android編碼和想改變屏幕亮度創建一個小程序... 嗯..我知道已經有一些關於它的問題,但我想這裏的一切建議,真的不知道我怎麼能解決我的問題:) 我知道你必須在設置亮度後「刷新」屏幕。在這一點上,我的問題開始了......我創建了一些虛擬活動,並且在我的主要活動中也有一個意圖,但好像意圖不打開虛擬活動......這裏有我主要的相關部分活性:啓動虛工作
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...
}
和僞代碼:
public class DummyBrightnessActivity extends Activity{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
this.finish();
}
}
所述的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>
也許相關的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>
哦,順便說一句...我沒有得到任何錯誤...啞只是不會開始(我是這麼認爲的,因爲當我沒有Android運行:excludeFromRecents =「true」,那麼它不會出現在最近的應用程序列表中。
我希望有人能幫助我... 有一個愉快的一天
//編輯:嗯......它看起來像代碼工作正常的xD 只是relooked並把一些文字來代替「完成()「和活動正常運行......但我認爲完成必須在那裏:/ 也許你有什麼建議如何」重置「屏幕呢?貌似我理解錯的教程之一...
// EDIT2: 嗯......我不能發佈一個答案,在第一8小時我自己的問題:d 所以我將它張貼在這裏:
謝謝大家的幫助和提示,但是現在我發現了我自己的解決方案:D 這一個:Refreshing the display from a widget? 「開啓一個空活動並執行WindowManager刷新」部分正在爲我工作。 我碰到這個問這裏之前,但當時我只是不可能得到它的工作:d 所以,不管怎麼說,非常感謝你;) 這只是艱苦的一個例子也可以是代碼「一點,快-coded初學者應用」;)
我沒有答案,但因爲你看起來像我想我會在免得給你一個替代資源的HTTP新用戶:/ /android.stackexchange.com/ – wavedrop