Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7061369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:27:56+00:00 2026-05-28T04:27:56+00:00

I have an app, that should be toddler safe. Meaning that, it blocks any

  • 0

I have an app, that should be toddler safe. Meaning that, it blocks any single key touch, yet handles long pressing for exiting the app.

This is so that, the toddler will be safe from doing (too) nasty things while playing.

Up to version 2.3.4 (Gingerbread), I succeeded in achieving this.
However, now I have two problems:

  1. On Android 3 (Honeycomb), I have the status bar notifications which can be pressed on. Also, I have the switch-windows key which can be pressed. The only thing I succeeded with it is to dim the status bar.

  2. On Android 4.0 (Ice Cream Sandwich) (using the emulator, I still don’t have a real device with this version), when calling the next code, I get an exception which cannot even be caught.

The exception:

java.lang.IllegalArgumentException: Window type can not be changed after the window is added.

The code:

@Override
public void onAttachedToWindow()
{
  this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
  super.onAttachedToWindow();
}

What can I do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:27:56+00:00Added an answer on May 28, 2026 at 4:27 am

    For Android version 4 (API 14 and up), it might be possible to use:

    getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
    

    However, on the emulator, it doesn’t block the home button, so it’s kinda useless.

    I still don’t know if it works fine on real devices.

    Maybe it’s possible to use the following workaround:
    Set the app as the default home screen app.
    If the home button was pressed while the application was active, capture it and do nothing.
    If the home button was pressed while the application was on the background (or closed), open the previously selected default home app.

    Alternatively, I could ask the user to set the default home launcher app as mine for each time it is started, and reset it again (either to the previous one, or total reset) after it is closed.

    Is it possible? If so, how?


    Since Android 5.0 (Lollipop) (version 5.0 which is API 21), there is a way of screen-pinning, and this can be turned on by the user or the app (link here):

    There are two ways to activate screen pinning:

    Manually: Users can enable screen pinning in Settings > Security >
    Screen Pinning, and select the tasks they want to pin by touching the
    green pin icon in the recents screen. Programmatically: To activate
    screen pinning programmatically, call startLockTask() from your app.
    If the requesting app is not a device owner, the user is prompted for
    confirmation. A device owner app can call the setLockTaskPackages()
    method to enable apps to be pinnable without the user confirmation
    step.

    What does it do? Read further and see:

    When task locking is active, the following behavior happens:

    The status bar is blank, and user notifications and status information
    are hidden. The Home and Recent Apps buttons are hidden. Other apps
    cannot launch new activities. The current app can start new
    activities, as long as doing so does not create new tasks. When screen
    pinning is invoked by a device owner, the user remains locked to your
    app until the app calls stopLockTask(). If screen pinning is activity
    by another app that is not a device owner or by the user directly, the
    user can exit by holding both the Back and Recent buttons.

    Not only that, but according to this post, you can also toggle this without user-confirmation, and exiting this special state would be under your app’s logic.

    It seems like the perfect thing for toddler safe app.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My app should implement login with facebook but I have noticed that every time
I do have an app that should only be visible in the market for
I have a custom RatingBar in my app that should display either the site
I have an app that should play 3 distinct sounds and I define them
I have an app that contains configuration settings that should be changed only by
So I have an MVC app that should change the Website title, and header
I am developing an app that should have similar functionalities as the game in
I have an Android app that should open links sent via email. I only
I have a WinForms app that should be really easy to deploy with just
I have this weird problem.. I'm building an in-house app that should register all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.