我最近开始的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