2012-05-21 47 views
1

我開發了自己的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> 

+0

您可以通過該按鈕單擊事件來調用家中的活動。 –

+0

它不會幫助兄弟...請你解釋一下嗎? – Vervatovskis

+0

請大家今天我可以解僱! – Vervatovskis

回答

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()

+0

它的工作原理...謝謝兄弟! – Vervatovskis