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?