Java 活动必须导出或包含意图过滤器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40508303/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 22:45:25  来源:igfitidea点击:

The activity must be exported or contain an intent-filter

javaandroidandroid-activity

提问by Fahda.Shalhoub

when I tried to run my application its show the error below

当我尝试运行我的应用程序时,它显示以下错误

Error running Dashboard: The activity must be exported or contain an intent-filter

How can I solve this error?

我该如何解决这个错误?

回答by Houssem Cherif

just add intent-filter Tag inside your activity

只需在您的活动中添加意图过滤器标签

for example ::

例如 ::

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

回答by yfsx

Double check your manifest, your first activity should have tag

仔细检查你的清单,你的第一个活动应该有标签

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

inside of activity tag.

活动标签内。

If that doesn't work, look for target build, which located in the left of run button (green-colored play button), it should be targeting "app" folder, not a particular activity. if it doesn't targeting "app", just click it and choose "app" from drop down list.

如果这不起作用,请查找位于运行按钮(绿色播放按钮)左侧的目标构建,它应该针对“app”文件夹,而不是特定活动。如果它不针对“应用程序”,只需单击它并从下拉列表中选择“应用程序”。

Hope it helps!

希望能帮助到你!

回答by dipesh

I changed the Select Run/Debug Configurationfrom my MainActivityto Appand it started working. Select App configuration snapshot:

我将其Select Run/Debug Configuration从 my更改MainActivityApp并开始工作。选择应用配置快照:

enter image description here

在此处输入图片说明

回答by Raheel Khan

Just Select App from dropdown menu with Run(green play icon). it will run the whole the App not the specific Activity. if it doesn't help try to use in that activity in ManiFest.xml file. thankyou

只需从带有运行的下拉菜单中选择应用程序(绿色播放图标)。它将运行整个应用程序而不是特定的活动。如果它没有帮助尝试在 ManiFest.xml 文件中的那个活动中使用。谢谢你

回答by Diego Venancio

In manifest.xml, select activity which u wanna start e set this informations:

在 manifest.xml 中,选择您要启动的活动并设置以下信息:

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

回答by Usama Tahir

Check your manifest,Open the file with .xml extension and then all your activities are listed your first activity should have this code enclosed in its tags

检查您的清单,打开带有 .xml 扩展名的文件,然后列出您的所有活动,您的第一个活动应该将此代码包含在其标签中

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

or there is another way u can choose from configuration which is drop down list on the left side of run button choose from App from it Hope it will help!!

或者还有另一种方式,你可以从运行按钮左侧的下拉列表中选择配置,从中选择应用程序希望它会有所帮助!!

回答by Ehsan.sarshar

it's because you are trying to launch your app from an activity that is not launcher activity. try run it from launcher activity or change your current activity category to launcher in android Manifest.

这是因为您试图从不是启动器活动的活动中启动您的应用程序。尝试从启动器活动运行它或将您当前的活动类别更改为 android Manifest 中的启动器。

回答by Sagar Patel

First check a Launch Activity is set in your 'manifest.xml' file has:

首先检查您的“ manifest.xml”文件中是否设置了启动活动:

<activity android:name=".{activityName}">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

If this is set correctly, next check your run/debug configuration is set to 'App',

如果设置正确,接下来检查您的运行/调试配置是否设置为“ App”,

enter image description here

在此处输入图片说明

If the 'App' configuration is missing - you will need to add it by first selecting 'Edit Confurations'

如果缺少“应用程序”配置 - 您需要先选择“编辑配置”来添加它

enter image description here

在此处输入图片说明

If you do not have a 'App' configuration you will need to create one, else select you 'App' configuration and skip the creating steps. Also if your configuration is corrupt you may need to delete it but first backup your project. To delete a corrupt configuration, select it by expanding the 'Android App' node and chose the '-' button.

如果您没有“ App”配置,则需要创建一个,否则选择“ App”配置并跳过创建步骤。此外,如果您的配置已损坏,您可能需要将其删除,但首先要备份您的项目。要删除损坏的配置,请通过展开“ Android App”节点并选择“ -”按钮来选择它。

enter image description here

在此处输入图片说明

To create a new configuration, select the '+' button and select 'Android App'

要创建新配置,请选择“ +”按钮并选择“Android App”

enter image description here

在此处输入图片说明

If you have just created the configuration you will be presented with the following default name value of 'Unnamed' and module will have the value '<no module>' then hit 'Apply' and 'OK'.

如果您刚刚创建了配置,您将看到以下默认名称值“ Unnamed”,模块将具有值“ <no module>”,然后点击“ Apply”和“ OK”。

enter image description here

在此处输入图片说明

Set this the name to 'App' and select 'app' as the module.

将此名称设置为“ App”并选择“ app”作为模块。

enter image description here

在此处输入图片说明

Next select 'App' as the run configuration and Run.

接下来选择“ App”作为运行配置并运行。

enter image description here

在此处输入图片说明

Thats it!

就是这样!

回答by Tony Merritt

Sometimes if you change the starting activity you have to click edit in the run dropdown play button and in app change the Launch Options Activity to the one you have set the LAUNCHER intent filter in the manifest.

有时,如果您更改启动活动,您必须单击运行下拉播放按钮中的编辑,并在应用程序中将启动选项活动更改为您在清单中设置的 LAUNCHER 意图过滤器。

回答by Ganesh

If you're trying to launch a specific activity instead of running the launcher one. When you select that activity. the android studio might through this error, Either you need to make it launcher activity, just like answered by few others. or you need to add android:exported="true"inside your activity tag inside manifest. It allows any external tool to run your specific activity directly without making it a launcher activity

如果您尝试启动特定活动而不是运行启动器。当您选择该活动时。android studio 可能会通过这个错误,要么你需要让它启动器活动,就像其他人回答的那样。或者您需要android:exported="true"在清单内的活动标签内添加。它允许任何外部工具直接运行您的特定活动,而无需将其设为启动器活动