添加了他的申请到"新增到主屏幕" /"快捷"部分 [英] Adding his application to the "add to Home screen"/"Shortcut" section

查看:105
本文介绍了添加了他的申请到"新增到主屏幕" /"快捷"部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Andr​​oid应用程序,我在我的应用程序中创建由code快捷键一些活动。我通过使用广播做此功能:

In my android application, I create shortcuts by code to some activities within my application. I do this feature by using the broadcast:

    intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
    sendBroadcast(intent);

和这很酷,真正的工作!

and that's cool, that really work!

现在我想做些不同的事:我已经看到了一些行动可以注册的地方在Android菜单,当这样一个家庭,你长的preSS加入:

Now I would like to do something different: I have seen that some actions can "register" somewhere to be added in the Android menu, when you long press on the Home like this one:

<一个href=\"http://www.androidtapp.com/wp-content/uploads/2010/02/UltimateFaves-Add-Home-Screen-Shortcut.jpg\" rel=\"nofollow\">http://www.androidtapp.com/wp-content/uploads/2010/02/UltimateFaves-Add-Home-Screen-Shortcut.jpg

所以我的主要问题是下一个:

So my main question is the next one:

这怎么可能为这个菜单注册。我想有一些线在清单中添加,但看不到的地方做!

How is that possible to register for this menu. I guess there is some line to add in the manifest, but cannot see where to do that!

感谢很多的帮助!

顺便说一句,还有一个次要的问题:有一次我都会有成功的这样做,我可以加入我的菜单不同数量的快捷方式(想象一下,我想这样做,对于多账号的Twitter客户端,我想看到每个Twitter帐户不同在此列表中。)所以快捷键的数量programmaticaly计算。

BTW, there is a secondary question: once i will have succeed doing that, may I add a different number of shortcuts in my menu ( imagine That I would like to do that for a multi-account twitter client, I would like to see a different for each twitter account in this list.) So the number of shortcut is programmaticaly computed.

推荐答案

刚刚发现我的答案SDK样本:

Just found my answer in the SDK samples:

    <!-- This section of sample code shows how your application can add shortcuts to -->
    <!-- the launcher (home screen).  Shortcuts have a three step life cycle. -->

    <!-- 1.  Your application offers to provide shortcuts to the launcher.  When -->
    <!--     the user installs a shortcut, an activity within your application -->
    <!--     generates the actual shortcut and returns it to the launcher, where it -->
    <!--     is shown to the user as an icon. -->

    <!-- 2.  Any time the user clicks on an installed shortcut, an intent is sent. -->
    <!--     Typically this would then be handled as necessary by an activity within -->
    <!--     your application. -->

    <!-- 3.  The shortcut is deleted.  There is no notification to your application. -->

    <!-- In order provide shortcuts from your application, you provide three things: -->

    <!-- 1.  An intent-filter declaring your ability to provide shortcuts -->
    <!-- 2.  Code within the activity to provide the shortcuts as requested -->
    <!-- 3.  Code elsewhere within your activity, if appropriate, to receive -->
    <!--     intents from the shortcut itself. -->

    <activity android:name=".LauncherShortcuts"
              android:label="launchers">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.SAMPLE_CODE" />
        </intent-filter>

    </activity>

    <!-- It is recommended that you use an activity-alias to provide the "CREATE_SHORTCUT" -->
    <!-- intent-filter.  This gives you a way to set the text (and optionally the -->
    <!-- icon) that will be seen in the launcher's create-shortcut user interface. -->

    <activity-alias android:name=".CreateShortcuts"
        android:targetActivity=".LauncherShortcuts"
        android:label="test">

        <!--  This intent-filter allows your shortcuts to be created in the launcher. -->
        <intent-filter>
            <action android:name="android.intent.action.CREATE_SHORTCUT" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

这篇关于添加了他的申请到&quot;新增到主屏幕&QUOT; /&QUOT;快捷&QUOT;部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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