2010-08-25 25 views
3

我在Android中创建一个很酷的家庭应用程序。在启动器中创建第二个快捷方式

由于这是一款家庭应用程序,我不希望她出现在启动器中的所有应用程序列表中。

这很容易,但现在我想这个应用程序的设置出现。所以,我创建我的应用程序的喜好这样的清单:

<activity android:name=".Preferences" android:label="@string/application_name"> 
<intent-filter> 
     <action android:name="android.intent.action.MAIN" /> 
     <category android:name="android.intent.category.LAUNCHER" /> 
</intent-filter> 
</activity> 

这工作得很好,我必须在启动额外的图标!

唯一的问题是没有任何反应,当我点击图标。因此,我可以从应用程序中启动我的偏好:

final Intent preferences = new Intent(Launcher.this,Preferences.class);   
menu.add(0, MENU_PREFERENCES, 0, R.string.application_name).setIcon(
     R.drawable.ic_menu_preferences).setAlphabeticShortcut('F').setIntent(
      preferences); 

那么,为什么启动器中的快捷方式完全无用,并且不推出什么吗?

更多的信息在这里:当我从应用程序中启动

日志(偏好推出,完美地工作):

08-25 13:13:03.009: INFO/ActivityManager(63): Starting activity: Intent { cmp=com.myapp.home/.Preferences } 

当我从发射器发射(没有任何反应):

08-25 13:13:45.489: INFO/ActivityManager(63): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.myapp.home/.Preferences } 

我的活动:

public class Preferences extends PreferenceActivity { 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    addPreferencesFromResource(R.xml.preferences); 

} 
} 

回答

1

刚刚发现了一些东西! (而顺便说一句,是什么时,我找到了答案,以我自己的问题用最好的方法我应该回答自己在这里..?)

我不得不使用在清单:

 <activity android:clearTaskOnLaunch="true" android:launchMode="singleTask" android:stateNotNeeded="true" (...other parameters...)> 

       <intent-filter> 
          <action android:name="android.intent.action.MAIN" /> 
          <category android:name="android.intent.category.LAUNCHER" /> 
       </intent-filter> 
     </activity> 

这工作相当好!

+0

回答自己很好 – Falmarri 2010-08-25 19:56:17