문제

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?

도움이 되었습니까?

해결책

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>

다른 팁

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?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top