创建在启动第二个快捷键 [英] Creating a second shortcuts in the Launcher

查看:145
本文介绍了创建在启动第二个快捷键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建Android中一个很酷的应用首页

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

这是pretty容易的,但现在我想这个应用程序显示的设置。所以,我创建我的应用程序的preferences在清单中是这样的:

 <活动机器人:preferencesNAME =机器人:标签=@字符串/ APPLICATION_NAME>
&所述;意图滤光器>
       <作用机器人:名字=android.intent.action.MAIN/>
       <类机器人:名字=android.intent.category.LAUNCHER/>
 &所述; /意图滤光器>
< /活性GT;

这工作pretty很好,我已经在启动一个额外的图标!

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

 最终意图$​​ P $ pferences =新意图(Launcher.this,preferences.class);
menu.add(0,MENU_ preFERENCES,0,R.string.application_name).setIcon(
        R.drawable.ic_menu_ preferences).setAlphabeticShortcut(F)。setIntent(
          preferences);

那么,为什么快捷的发射完全无用,不发动什么吗?

在这里更多的信息:

当我从应用程序中启动日志(preferences被发射,完美地工作):

  08-25 13:13:03.009:信息/ ActivityManager(63):启动活动:意向{CMP = com.myapp.home /.preferences}

当我从发射器发射(的什么也没有发生的):

  08-25 13:13:45.489:信息/ ActivityManager(63):启动活动:意向{行动= android.intent.action.MAIN猫= [android.intent.category .LAUNCHER] FLG = 0x10200000 CMP = com.myapp.home /.preferences}

我的活动:

 公共类preferences扩展$ P $ {pferenceActivity @覆盖
 保护无效的onCreate(捆绑savedInstanceState){
  super.onCreate(savedInstanceState);
  加preferencesFromResource(R.xml preferences); }
}


解决方案

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

我不得不使用在清单:

 <活动机器人:clearTaskOnLaunch =真正的机器人:launchMode =singleTask机器人:stateNotNeeded =真(...其他参数...)>                &所述;意图滤光器>
                          <作用机器人:名字=android.intent.action.MAIN/>
                          <类机器人:名字=android.intent.category.LAUNCHER/>
                &所述; /意图滤光器>
      < /活性GT;

这工作pretty好!

I'm creating a cool Home application in Android.

As this is a Home app I don't want her to appear in the Launcher, in the list of all applications.

That's pretty easy, but now I would like the settings of this application to appear. So, I created the preferences of my application this way in the 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>

That work pretty well and I have an extra icon in the Launcher!

The only problem is that nothing happens when I click on the Icon. Therefore, I can launch my Preferences from within the application:

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

So, why is the shortcut in the launcher totally useless and does not launch anything?

More informations here:

Log when I launch from within the application (preferences are launched, worked flawlessly):

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

When I launch from the launcher (nothing happens):

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 }

My activity:

public class Preferences extends PreferenceActivity {

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

 }
}

解决方案

Just found something! (And btw, what is the best procedure to use when I found an answer to my own question? Should I answer myself? here..)

I had to use that in 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>

That work pretty well!

这篇关于创建在启动第二个快捷键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆