Udi Oshi
Udi Oshi

Reputation: 6867

Show UI (Activity/WindowManager) over lock screen & support in Oreo

My main goal is to show UI (With EditText, so IME support) Over the lock screen (No matter if there's PIN/Code or simple lock screen).

I know that WhatsApp application is doing it (Settings > Notification > Always show popup) so there's a solution for that.

The UI must be initialized from Service.

The view is a simple textview:

    textview = new TextView(this);
    textview.setText("Hello There!");
    textview.setTextColor(ContextCompat.getColor(this, 
    android.R.color.white));
    textview.setTextSize(32f);

I've tried several ways so far: (In order to reproduce like whats app i'm doing everything when screen off receiver called)

Any other suggestions?

Thanks.

Upvotes: 1

Views: 2263

Answers (1)

shmakova
shmakova

Reputation: 6426

Add this in onCreate() of your Activity:

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
}

Upvotes: 4

Related Questions