Need help,Screen didn't turn on after I change Activity's theme
I'm making my alarm app. There is an Activity to show alarm infomation. I want turn on the screen and unlock it. I wrote these code
AlarmActivity.java:
public class AlarmActivity extends Activity { ...... void onCreate(Bundle bl) { ..... final Window win = getWindow(); win.requestFeature(android.view.Window.FEATURE_NO_TITLE); win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); LayoutInflater inflater = LayoutInflater.from(this); setContentView(inflater.inflate(R.layout.alarm, null)); } ...... }
AndroidManifest.xml
{activity android:name="AlarmTaskActivity" android:excludeFromRecents="true" android:theme="@android:style/Theme.Wallpaper.NoTitleBar" android:launchMode="singleInstance" android:taskAffinity="" android:configChanges="orientation|keyboar开发者_JS百科dHidden|keyboard|navigation"/}
It's ok,but when I change
android:theme="@android:style/Theme.Wallpaper.NoTitleBar" to android:theme="@android:style/Theme.Dialog" the screen did not turn on nor unlock, I am really confused....Can you please tell me how to make the screen turn on and unlock when I use "@android:style/Theme.Dialog"?
Thanks
by the way,I have android 2.0 in my test device.
In order to activate the screen and force it to stay on, you need to use a WakeLock.
See the documentation for more information. Changing the theme along won't cause the screen to wake up. You'll need to use the ACQUIRE_CAUSES_WAKEUP
flag in order to do that.
精彩评论