两个发射活动 [英] Two launcher activities

查看:107
本文介绍了两个发射活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经打上意图过滤器两种活动

I have two activities marked with intent filter

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.package"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="7" />

<application
    android:name=".MyApp"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >

    <!-- work order activity -->
    <activity
        android:name=".app.WorkOrderActivity"
        android:label="@string/work_order"
        android:taskAffinity="com.package.task_for_work_order_activity" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

    <!-- inventory activity -->
    <activity
        android:name=".app.InventoryActivity"
        android:label="@string/inventory"
        android:taskAffinity="com.package.task_for_inventory_activity" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

现在的问题是,当我安装apk文件,没有显示出有活性的,因为,我的理解系统不能指定哪些活动应该显示。

The problem is, that when I'm installing apk file, there is no activity shown, because, as I understood system can't specify what activity should be shown.

我真的很需要两个发射器显示的活动,所以请不要给意见有关从次活动除去意图过滤器,或者如果你这样为我提供另一种方式展现在发射两个图标。

I just really need two activities shown in launcher, so please don't give advice about removing intent-filters from second activity, or if you do so provide me another way to show two icons in launcher.

在此先感谢。

推荐答案

您需要指定通过添加下面一行到你的意图,过滤器,它的活动是默认的:

You need to specify which activity is the default one by adding the following line to your intent-filter:

<category android:name="android.intent.category.DEFAULT"/>

插入此默认行为,并保持休息。那么它应该工作。

Insert this in the default activity and keep the rest. Then it should work.

您可能还需要添加不同的图标,你的第二个活动与属性安卓图标=@可绘制/ myothericon

You may also want to add a different icon to your 2nd activity with the attribute android:icon="@drawable/myothericon"

这篇关于两个发射活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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