启动器中的按钮主页不起作用

时间:2012-05-21 13:11:35

标签: android launcher

我开发了自己的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>

1 个答案:

答案 0 :(得分:1)

查看Home - 自定义启动器示例。这里有一个关键事件的调度员:

@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()调用以隐藏应用程序网格。