如何讓一個activity 浮在鎖定畫面的上方,返回即進入解鎖介面。
譬如在鎖定畫面,來電時是不需要先解鎖才能電話中的。這樣能帶來快捷。
如果你想在android 上實現 iphone 4s 上面在鎖定畫面就能進照相機的話也可以按此方式來進行。
只需要在 Camera 的 activity 的 onResume 函數中添加如下 flag 即可實現。
import android.view.Window;
import android.view.WindowManager;
final Window win = activity.getWindow();
final WindowManager.LayoutParams params = win.getAttributes();
params.flags |= WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
/** Window flag: special flag to let windows be shown when the screen
* is locked. This will let application windows take precedence over
* key guard or any other lock screens. Can be used with
* {@link #FLAG_KEEP_SCREEN_ON} to turn screen on and display windows
* directly before showing the key guard window. Can be used with
* {@link #FLAG_DISMISS_KEYGUARD} to automatically fully dismisss
* non-secure keyguards. This flag only applies to the top-most
* full-screen window.
*/
public static final int FLAG_SHOW_WHEN_LOCKED = 0x00080000