I work on a kiosk app which can launch other android apps. It runs on top of the lockscreen. The issue I am seeing is that the lockscreen is displayed briefly between activities. We must keep the tablet locked so unlocking is not an option.
I have been able reproduce this with a super simple case. Both activities are nearly identical. The application is a device administrator and can be displayed above the keyguard. I have also tried not using finish()
at all but that didn't fix the issue.
public class MainActivity extends Activity {
private Handler h = new Handler();
@Override
protected void onCreate(Bundle savedInstanceState) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button bneg1 = (Button) findViewById(R.id.bneg1);
bneg1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
h.post(new Runnable() {
@Override
public void run() {
Intent i = new Intent(MainActivity.this, SecondActivity.class);
startActivity(i);
finish();
}
});
}
});
}
}
How can I launch the other activity without it briefly showing the lockscreen first?
To enable it you have to go to the app configuration -> Other permissions -> Show On Lock screen.
In general, a lock screen is an interface on a computer, smartphone, or tablet that appears upon startup. Access to all of the device's applications are limited when it is locked, preventing unwanted users from accessing the device's contents and settings.
How can I launch the other activity without it briefly showing the lockscreen first?
An easier way of achieving this would be to have a dummy (plain-view) activity running before you launch activity-1
. This way, when you do finish activity-1
, dummy-activity
will take over, followed by activity-2
coming into the foreground.
You will (most likely) also need to tell the system not to provide window animations. Do so by adding this to your application theme:
<item name="android:windowAnimationStyle">@null</item>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With