简体   繁体   English

错误:包含广播接收器的应用程序的“未找到默认活动”

[英]Error: 'Default Activity Not Found' for an app containing a Broadcast receiver

I have two separate apps. 我有两个单独的应用程序。

The first sends out two different kinds of Broadcasts. 第一个发出两种不同的广播。

The second one waits for this broadcast from App #1 and uses the broadcast to decide what activity to launch. 第二个广播等待来自App#1的广播,并使用广播来决定要启动的活动。

What I'm confused about is this: It seems to me that App #2 (the receiving app) shouldn't necessarily require a default activity since the activity it launches depends on the broadcast received from App #1. 我对此感到困惑:在我看来,应用程序2(接收方应用程序)不一定需要默认活动,因为它启动的活动取决于从应用程序1接收到的广播。

But, if a default activity is not defined in App #2, it can't run and throws: 但是,如果未在App#2中定义默认活动,则它将无法运行并引发:

Error running app: Default activity not found 运行应用程序时出错:找不到默认活动

But, if I do define one in the manifest file, then this defeats the purpose of the Broadcast. 但是,如果我确实在清单文件中定义了一个,那么就无法实现广播的目的。

Please help me understand the bigger picture and maybe offer a solution. 请帮助我了解全局,并提供解决方案。

UPDATE : The issue is solved. 更新 :问题已解决。 To the people facing the same problem, I found 2 possible ways to resolve this: 对于面临相同问题的人们,我发现了两种可能的解决方法:

  • As suggested by @Lemi Miles, We can simply go to App>edit Configurations> On launch options and choose Launch "Nothing". 正如@Lemi Miles所建议的那样,我们只需转到“应用程序”>“编辑配置”>“启动选项”,然后选择“启动”即可。
  • Alternatively, you could create an activity with no functionality to act as a launcher activity for the app 或者,您可以创建一个没有功能的活动来充当应用程序的启动器活动

应用程序>编辑配置>在启动选项中,选择启动“无”

I had this problem since 3 days.. If you are sure that there is no problem in your manifest.xml then Here is a solution... 1)Delete Android.3.1 or which version folder you have from c/User/Android.your version... 2)Then start Android again.. 自3天以来,我就遇到了这个问题。.如果您确定manifest.xml中没有问题,那么这是一种解决方案... 1)从c / User / Android删除Android.3.1或哪个版本的文件夹。您的版本... 2)然后再次启动Android。

It worked for me.. 它对我有用。

I had the same problem. 我有同样的问题。 Try this: In Android Studio Tool Bar -> select Run->Edit Configuration-> On Launch Option ->Select Nothing in place of Default Activity 尝试以下操作:在Android Studio工具栏中->选择“运行”->“编辑配置”->“启动选项”->“不选择任何内容代替默认活动”

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

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