2

我已经开发了自己的 Android 启动器,它运行良好,问题是当我单击 HOME 按钮时它不会将我重定向到 HOME 页面,我该如何解决这个问题,谢谢!

这是我的清单文件:

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

<uses-sdk android:minSdkVersion="8" />

<uses-permission android:name="android.permission.INTERNET" />

<permission
    android:name="com.android.launcher.permission.INSTALL_SHORTCUT"
    android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
    android:protectionLevel="normal" />
<permission
    android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT"
    android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
    android:protectionLevel="normal" />
<permission
    android:name="com.android.launcher.permission.READ_SETTINGS"
    android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
    android:protectionLevel="normal" />
<permission
    android:name="com.android.launcher.permission.WRITE_SETTINGS"
    android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
    android:protectionLevel="normal" />

<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
<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.SET_WALLPAPER_HINTS" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.BIND_APPWIDGET" />
<uses-permission android:name="com.android.launcher.permission.READ_SETTINGS" />
<uses-permission android:name="com.android.launcher.permission.WRITE_SETTINGS" />

<application
    android:name="STB"
    android:icon="@drawable/icon"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
    <activity
        android:name=".testingactivity.CoverFlowTestingActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <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.LAUNCHER" />
            <category android:name="android.intent.category.MONKEY" />
        </intent-filter>
    </activity>
    <activity
        android:name="pl.polidea.coverflow.testingactivity.PagerLauncherActivity"
        android:label="@string/app_name" >
    </activity>
    <activity
        android:name="pl.polidea.coverflow.testingactivity.GameActivity"
        android:label="@string/app_name" >
    </activity>
    <activity
        android:name="pl.polidea.coverflow.testingactivity.CinemaActivity"
        android:label="@string/app_name" >
    </activity>
    <activity
        android:name="pl.polidea.coverflow.testingactivity.Black"
        android:label="@string/app_name" >
    </activity>
    <activity
        android:name="pl.polidea.coverflow.testingactivity.CommunicationActivity"
        android:label="@string/app_name" >
    </activity>
    <activity
        android:name="pl.polidea.coverflow.testingactivity.InternetActivity"
        android:label="@string/app_name" >
    </activity>
    <activity
        android:name="pl.polidea.coverflow.testingactivity.LiveActivity"
        android:label="@string/app_name" >
    </activity>
    <activity
        android:name="pl.polidea.coverflow.testingactivity.MusicActivity"
        android:label="@string/app_name" >
    </activity>
    <activity
        android:name="pl.polidea.coverflow.testingactivity.SettingsActivity"
        android:label="@string/app_name" >
    </activity>
    <activity
        android:name="pl.polidea.coverflow.testingactivity.SocialActivity"
        android:label="@string/app_name" >
    </activity>
    <activity
        android:name="pl.polidea.coverflow.testingactivity.TvShowActivity"
        android:label="@string/app_name" >
    </activity>
    <activity
        android:name="pl.polidea.coverflow.testingactivity.ApplicationActivity"
        android:label="@string/app_name" >
    </activity>

    <receiver android:name="pl.polidea.coverflow.testingactivity.ApplicationBroadcastService" >
        <intent-filter>
            <action android:name="android.intent.action.PACKAGE_INSTALL" />
            <action android:name="android.intent.action.PACKAGE_ADDED" />

            <data android:scheme="package" />
        </intent-filter>
    </receiver>
</application>

4

1 回答 1

1

查看主页- 自定义启动器示例。这是其中的关键事件调度程序:

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
            ...
            case KeyEvent.KEYCODE_HOME:
                mHomeDown = true;
                return true;
        }
    } else if (event.getAction() == KeyEvent.ACTION_UP) {
        switch (event.getKeyCode()) {
            ...
            case KeyEvent.KEYCODE_HOME:
                if (!event.isCanceled()) {
                    // Do HOME behavior.
                }
                mHomeDown = true;
                return true;
        }
    }

    return super.dispatchKeyEvent(event);
}

您可以在评论中执行您自己的行为。在此示例的情况下,将hideApplications()调用隐藏应用程序网格。

于 2012-05-21T14:57:28.607 回答