简体   繁体   English

Android:应用创建失败(隐含意图)

[英]Android:app creation malfunction(Implicit Intent)

I have two applications where the one opens by implicit intent the other one.So in the first application I create an Intent and where I wrote i.setAction("com.example.secondApp"); 我有两个应用程序,其中一个应用程序通过implicit intent打开另一个应用程序。因此,在第一个应用程序中,我创建一个意图,并在其中编写了i.setAction("com.example.secondApp"); and I launch it through startActivity(i); 然后通过startActivity(i);启动它startActivity(i);

Then on the second app I change the manifest(filter) like: 然后在第二个应用程序上,我将manifest(filter)更改为:

  <intent-filter>
           <action android:name="com.example.secondApp" />

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

plus I do all the creation intent in the java section. 另外,我在Java部分中完成了所有创建意图。

*code tested because everything was done by explicit intent in the first place and worked fine *代码经过了测试,因为所有事情都首先是由显式意图完成的,并且运行良好

So my point is when I try to run them both the first app installs nicely where the second one says that No Launcher activity found! 所以我的意思是,当我尝试同时运行两个应用程序时,第一个应用程序安装得很好,第二个应用程序显示No Launcher activity found! obviously cause I changed it but despite it installs it isn't shown on the phone nor the first App detects the second one,any clue? 显然是因为我更改了它,但是尽管安装了它,但它没有显示在手机上,也没有第一个应用程序检测到第二个,有什么线索吗?

*Also when I leave the manifest(filter) of the second app at default values it installs fine. *此外,当我将第二个应用的清单(过滤器)保留为默认值时,它也可以很好地安装。

If you want an activity to appear in the launcher, it needs the appropriate <intent-filter> : 如果您希望活动显示在启动器中,则需要适当的<intent-filter>

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

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

If you want that activity to have another <intent-filter> , that is fine. 如果您希望该活动具有另一个 <intent-filter> ,那就很好。 An <activity> can have as many <intent-filter> elements as needed. <activity>可以根据需要包含任意多个<intent-filter>元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM