Error处理: 重提No Launcher activity found!

来源:互联网 发布:中国it系统集成商排名 编辑:程序博客网 时间:2024/05/20 04:50

Error处理: 重提No Launcher activity found!


重提No Launcher activity found!错误提示,及解决办法


Android应用开发中No Launcher activity found! 是常见的错误,而且解决办法也很简单。

做Android开发已经很久了,相信自己不会轻易犯这个错误,但是今天却又遇到;在AndroidManifest.xml文件中也很确定的已经添加了

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

问题在那里那?


先看具体代码吧

AndroidManifest.xml文件内容如下:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"    package="com.app.test"    android:versionCode="1"    android:versionName="1.0" >    <uses-sdk        android:minSdkVersion="9"        android:targetSdkVersion="15" />    <uses-permission android:name="android.permission.NFC" />    <uses-feature        android:name="android.hardware.nfc"        android:required="true" />    <application        android:allowBackup="true"        android:debuggable="true"        android:icon="@drawable/icon"        android:label="@string/app_name"        android:theme="@style/AppTheme" >        <activity            android:name="com.app.test.MainActivity"            android:label="@string/title_activity_main" >            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />                <action android:name="android.nfc.action.TAG_DISCOVERED" />            </intent-filter>        </activity>    </application></manifest>

运行时console中信息如下:


运行了多次均如此,也没发现什么情况造成的。

在实验多次之后,发现将AndroidManifest.xml做如下调整即可。

调整后的AndroidManifest.xml文件内容如下:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"    package="mexxen.app.test"    android:versionCode="1"    android:versionName="1.0" >    <uses-sdk        android:minSdkVersion="9"        android:targetSdkVersion="15" />    <uses-permission android:name="android.permission.NFC" />    <uses-feature        android:name="android.hardware.nfc"        android:required="true" />    <application        android:allowBackup="true"        android:debuggable="true"        android:icon="@drawable/icon"        android:label="@string/app_name"        android:theme="@style/AppTheme" >        <activity            android:name="mexxen.app.test.MainActivity"            android:label="@string/title_activity_main" >            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />            </intent-filter>            <intent-filter>                <category android:name="android.intent.category.TAG_DISCOVERED" />            </intent-filter>        </activity>    </application></manifest>


运行效果如下:



结论:


在指定启动主界面的Activity时,尽量不要把不相干的action以及category与LAUNCHER放在一个 <intent-filter>中。



----------------------------------

欢迎浏览、技术交流
请尊重劳动成果
转载请注明出处,谢谢!
http://blog.csdn.net/netwalk/article/details/35289751






0 0
原创粉丝点击