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 9210885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:10:34+00:00 2026-06-18T01:10:34+00:00

I am working on a research project for my university. The app will never

  • 0

I am working on a research project for my university. The app will never be put on the market and only used for research.

I have made a homescreen app by using the Google Homescreen sample code.
In there, I have made an activity that is a lockscreen.
While in there, the user should not be able to get out of the lock by pressing Home, Back, etc.
The Back-Button seems to be disabled, but the Home-Button is not.
I have tried several solutions from the internet and stackoverflow, which are all not working.

Here is the important code:

(Notice: Logcat shows “Button pressed: 4” for the Back-Button but nothing for the home button!)

In my Lock-Screen Activity:

 @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        Log.v(TAG, "BUTTON PRESSED: " + new Integer(keyCode).toString());

        if ((keyCode == KeyEvent.KEYCODE_BACK)) {
            return true;
        } else if ((keyCode == KeyEvent.KEYCODE_CALL)) {
            return true;
        }
        else if ((keyCode == KeyEvent.KEYCODE_HOME)){
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

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

It seems like the onAttachedToWindow() Method is not working since Android Version 4.
How can I disable the homebutton?

EDIT: Manifest file:

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.home" >

    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.GET_TASKS" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.SET_WALLPAPER" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
    <uses-permission android:name="android.permission.NFC" />
    <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />

    <permission android:name="android.permission.WRITE_SECURE_SETTINGS" >
    </permission>

    <application
        android:icon="@drawable/ic_launcher_home"
        android:label="@string/home_title" >
        <service android:name=".MyService" >
        </service>

        <activity
            android:name="Home"
            android:launchMode="singleInstance"
            android:stateNotNeeded="true"
            android:theme="@style/Theme" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.HOME" />
                <category android:name="android.intent.category.DEFAULT" />


            </intent-filter>

            <receiver android:name=".ScreenReceiver" >
                <intent-filter>
                    <action android:name="android.intent.action.SCREEN_ON" />
                    <action android:name="android.intent.action.SCREEN_OFF" />
                    <action android:name="android.intent.action.USER_PRESENT" />
                </intent-filter>
            </receiver>
        </activity>
        <activity
            android:name="Wallpaper"
            android:icon="@drawable/bg_android_icon"
            android:label="Wallpaper" >
            <intent-filter>
                <action android:name="android.intent.action.SET_WALLPAPER" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity android:name=".LockPage" >
            <intent-filter>
                <action android:name="android.intent.action.SCREEN_ON" />
                <action android:name="android.intent.action.SCREEN_OFF" />
                <action android:name="android.intent.action.USER_PRESENT" />
                <action android:name="android.nfc.action.NDEF_DISCOVERED" />
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.HOME" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.MONKEY" />
                <category android:name="android.intent.category.DEFAULT" />

                <action android:name="android.intent.action.MAIN" />

                <data android:mimeType="text/plain" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.nfc.action.NDEF_DISCOVERED" />

                <category android:name="android.intent.category.DEFAULT" />

                <data android:scheme="http" />
            </intent-filter>
        </activity>
    </application>

</manifest>
  • 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-06-18T01:10:35+00:00Added an answer on June 18, 2026 at 1:10 am

    This may come a bit late, I have been on a somewhat similar situation. My problem was that I didn’t want users to leave the call screen during phone calls but I couldn’t prevent it, so instead I simply brought it back front every time they left it.

    In your case you could simply bring your app back to front on pause:

    @Override
    protected void onPause() {
        super.onPause();
            // Close and reopen app or bringToFront()
    }
    

    So leaving would automatically open the app again. You should try either reopening your activity or bringing it to front and see what works best. Reopening may be unnoticeable if you remove all animations and add FLAG_ACTIVITY_NO_ANIMATION.

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

Sidebar

Related Questions

I have a project which our research lab is working, but only a few
I'm working on my first major Cocoa app for an undergraduate research project. The
i will be working on a project that tries to determine your position using
I am working on a research project that deals with social networks. I have
I am currently working on a research project for a University in which I
I'm working on an Azure based project for some research and have been running
I'm working on research project using Microsoft BI Stack and Oracle Database. When working
I have a research project I'm working on. I am a beginner in C++
I am working on a research project in big data mining. I have written
I'm working on an app that will be used in public transit vehicles as

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.