【问题标题】:Creating a second shortcuts in the Launcher在启动器中创建第二个快捷方式
【发布时间】:2010-08-25 11:09:33
【问题描述】:

我正在 Android 中创建一个很酷的 Home 应用程序。

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

这很简单,但现在我希望显示此应用程序的设置。因此,我在 Manifest 中以这种方式创建了我的应用程序的首选项:

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

 }
}

【问题讨论】:

    标签: java android android-launcher android-homebutton


    【解决方案1】:

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

    我不得不在 Manifest 中使用它:

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

    效果很好!

    【讨论】:

      猜你喜欢
      • 2018-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-08
      • 1970-01-01
      • 2019-03-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多