无法识别启动活动:找不到默认活动 [英] Could not identify launch Activity: Default Activity not found

查看:391
本文介绍了无法识别启动活动:找不到默认活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是android新手,遇到了问题. 控制台说无法识别启动活动:找不到默认活动". 我添加了

I'm new to android and I have encounterded a problem. The console said that "Could not identify launch activity: Default Activity not found". I have add

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

清单中的

. 而且我尝试了无效的缓存/重新启动,仍然无法正常工作. 并且包含主要活动的类文件在android studio中变为绿色.我不知道那是什么意思 这是我的清单文件.

in manifests. And I have tried Invalidate caches/Restart,still not worked. And the class file which contains the main activity turn green in android studio. I don't know what that means. This is my manifests file.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mrrobot.mycoolweather" >
<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme" >
    <Activity       android:name="com.example.mrrobot.mycoolweather.activity.ChooseAreaActivity"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </Activity>
</application>

</manifest>

choiceAreaActivity是我要用作启动器活动的那个.

The chooseAreaActivity is the one I want to use as launcher activity.

推荐答案

对于清单中的主要活动,您必须将其添加为类别LAUNCHER(启动应用程序的第一个活动):

For main activity in your manifest you have to add this with category LAUNCHER (First Activity on launch app):

<activity
    android:name=".MainActivity"
    android:label="YourAppName"
    android:theme="@style/AppTheme.NoActionBar" >
      <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

对于其他活动,您必须将类别更改为DEFAULT:

For other activity you have to change category to DEFAULT:

<activity
    android:name=".OtherActivity"
    android:theme="@style/AppTheme.NoActionBar" >
    <intent-filter>
            <action android:name="package.OtherActivity" />

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

选中此活动和此所以您的代码是:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mrrobot.mycoolweather" >
<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme" >

    <activity
        android:name=".activity.ChooseAreaActivity"
        android:label="@string/app_name" >
          <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>

这篇关于无法识别启动活动:找不到默认活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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