i make a lock screen application that prevent other people to access the device when it's locked. i have an activity called lockscreen activity. here's the code:
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
public class LockScreen extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.lockscreen);
}
protected void onPause() {
super.onPause();
// it will display a lock screen again when the home button is pressed
Intent myIntent = new Intent(LockScreen.this, LockScreen.class);
myIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplication().startActivity(myIntent);
}
}
that code is used for relaunch the lockscreen activity when home button pressed, so that device can still locked. if i press the home button and didn't tap any application, it will show that lockscreen activity again within 5 second (based on android issue), but if i tap any application (eg: setting or messages) my lockscreen activity will shown after i close that application (the setting or messages is on the top and cover my lockscreen activity) so the device still can be accessed. has anyone know how to make an activity stay on top for minimize the access from unauthorized people? thanks..