Question

I'm programming an app that must stay on the screen of a tablet which is accessible by everyone.

This means that only people who know the passcode can access the tablet, while passing-by users can only use the app. However, I'm stuck on the home button. Is there any way to change it? Disable, control, anything?

Was it helpful?

Solution

You can make your application as a Home screen launcher app using very similar activity code in your AndroidManifest. This way when user press the home button your app will be opened.

    <activity
        android:name=".MainActivity"
        android:launchMode="singleTask"
        android:excludeFromRecents="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <!-- The following two intent-filters are the key to set homescreen -->
            <category android:name="android.intent.category.HOME" />
            <category android:name="android.intent.category.DEFAULT" />

        </intent-filter>
    </activity>

OTHER TIPS

It seems what you need to do is make a launcher to replace the default home screen. Otherwise there is no way to change the home key behavior.

To make a launcher, check this How to make a launcher

I have tried this on Android ICS and it works:

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

When i press the home button with this set in my Android manifest the activity automatically starts.(The first time it asks if i want to go to Xperia Home or Start my Application, i can also make that permanent)

Though i do have a question, I want to be able to open my application when i hold down the home button, how could i do this?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top