我試圖添加一個鎖定屏幕解鎖並顯示Activity
的Activity
。一切正常,除了解鎖屏幕。 Activity
開始,但屏幕保持關閉狀態。但我需要屏幕在Activity
開始的同時進行。Android活動解鎖屏幕
我用下面的代碼:
public void vibrate() {
if ((deltaX > vibrateThreshold) || (deltaY > vibrateThreshold) || (deltaZ > vibrateThreshold)) {
//http://www.androidauthority.com/android-7-0-features-673002/
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("My notification")
.setContentText("Hello World!")
.setPriority(Notification.PRIORITY_MAX);
NotificationManager notificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0, mBuilder.build());
Intent alarmIntent = new Intent("android.intent.action.MAIN");
alarmIntent.setClass(this, test.class);
alarmIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
alarmIntent.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
this.startActivity(alarmIntent);
new CountDownTimer(25000, 1000) {
public void onTick(long millisUntilFinished) {
//here you can have your logic to set text to edittext
}
public void onFinish() {
}
}.start();
}
}
在我AndroidManifest我有以下代碼:
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
謝謝,我如何讓屏幕繼續? –
我編輯了我的帖子,並提供了另一個問題的鏈接 – Denny