0

Please have a look at the attached image it shows screen that i want for my activity. I want to stop user from proceeding further until he enters correct password. I want to this screen to come up when my phone boots after restarting.

I have written listener for listener device boot process.

public class DeviceStartUpListener extends BroadcastReceiver
{

    @Override
    public void onReceive(Context context, Intent intent)
    {
        if(intent.getAction().equals("android.intent.action.BOOT_COMPLETED"))
        {
            // some code
            Intent authenticationIntent = new Intent(applicationContext, PostStartupAuthenticationActivity.class);
            authenticationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(authenticationIntent);
        }
    }
}

I want my PostStartupAuthenticationActivity to cover complete screen and ask user for password. This activity should hide all the button at bottom of screen. Your should not be able to move to any other activity until he enters correct password or until he enters wrong password for consecutive 3 times.

In PostStartupAuthenticationActivity i have written following code in onCreate method, but this is not working correctly, The activity is displayed full screen but the button at the bottom of screen are still visible eg home button and back button are still visible, I want activity to open in full screen mode but no button should visible at the bottom of screen, My present activity is looking like this, please find second attached image:-

@Override
protected void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);

    mIntent = getIntent();

    //set fullscreen and no title
    //        requestWindowFeature(Window.FEATURE_NO_TITLE);

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

setContentView(R.layout.post_starup_authentication_activity);
}

Thanks in advance. Activity should look like this an text box should be used for entering password.

benka
  • 4,732
  • 35
  • 47
  • 58
user3279837
  • 65
  • 1
  • 6
  • possible duplicate of [Android - Is It possible to disable the click of home button](http://stackoverflow.com/questions/2162182/android-is-it-possible-to-disable-the-click-of-home-button) – Acapulco Feb 06 '14 at 15:49

1 Answers1

1

If you are trying to make app which gonna lock the device by password - you not gonna achive it and your attempt to do it is useless. User always could press the hadware button "Home" and your app will gone on the background.
But if you want only to prevent user to use your particular app without passing the password screen - just dont start any activity before user enters correct password like:

if (entered_password_is_correct())
    start_next_corresponding_activity();
Stan
  • 6,511
  • 8
  • 55
  • 87
  • Hello Stan, I just want to validate user if he is genuine user or not. If he enters incorrect password for 3 consecutive times my activity will get minimized and further actions will be performed. if he enters correct password in 3 attempts he can proceed further with other task. I want similar to screen attached with this question. – user3279837 Feb 06 '14 at 16:04
  • I just want my activity to have layout same as the attached image. User should have no other option then to enter authentication code. I will block screen only to validate if he is a authenticated user. If he enters wrong code for 3 consecutive times current activity will get minimized and then he can carryout his tasks(but notification mechanism will start in this case). If he enters correct password then he can carryout his own tasks(no notification mechanism started in this case). – user3279837 Feb 06 '14 at 16:18
  • Ok, so you could use shown aproach for your app and like I said you can not lock the device by itself making user to authenticate, user always could press Home and say goodbuy to your authentication attempt. Could you get it? There was some tricky way to catch the Home pressing for aos 2.x but its not suitable for aos >3.0 which makes it useless. So user gonna press Home and then that user will be able to stop your impudent app and uninstall it totally. – Stan Feb 06 '14 at 20:13