0

I want to keep my activity on the user's screen when the home button is pressed. According to this question, I can do so by using "TYPE_SYSTEM_ALERT".

But I keep going to homescreen on home button click...

Here's my code:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Window w = getWindow();
    w.setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
    setContentView(R.layout.activity_my);
    ...
}
Community
  • 1
  • 1
  • I understand you reaction, but my activity can easily be finished with a button, so the user can go to the homescreen. Thanks for your opinion though – Jens-Joris Decorte Aug 01 '14 at 22:08
  • Just to tell, Facebook Messenger and MX Player also use this method. Don't see many people flushing those apps down their toilet :) – Jens-Joris Decorte Aug 01 '14 at 22:11
  • it's one thing to hide the home button while your app is fullscreen. that's expected behavior. but outright disabling it, nope... not a good idea. – Marc B Aug 01 '14 at 22:12
  • My app adds users to phone, and this activity starts when the phone gets turned on. Its the activity where you choose the user (+ type in password). I would like to be sure a user gets selected, that's why I want to implement this method. So I guess the user should be expecting this behaviour of such an app. – Jens-Joris Decorte Aug 01 '14 at 22:18

2 Answers2

0

I think for your use case you need to run a service(runs on bootup) which listens for app launches and which brings up login screen for the user if the he has not logged in so far..refer-Android, Detect when other apps are launched for how to do it.I have seen this approach in many market apps.

Community
  • 1
  • 1
rupesh jain
  • 3,410
  • 1
  • 14
  • 22
0

TYPE_SYSTEM_ERROR is what you need :)

A. N
  • 153
  • 1
  • 15