如何以正确的方式将Activity添加到manifest.xml? [英] How to add Activity to manifest.xml in right way?
本文介绍了如何以正确的方式将Activity添加到manifest.xml?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我应该在android清单中编写每个活动,如何进行?每个活动都必须有意图过滤器吗?
should I write each activity in android manifest and how? Must each activity have intent-filter, or not?
推荐答案
在清单文件中添加活动的多种方法.
Multiple ways to add activites in Manifest file.
意图过滤器不是所有活动的必需标记,它是可选的.
intent filter is not a necessary tag for all activites,it is optional.
在清单的应用程序标记中添加活动:
Add Activity in application tag in your manifest:
<!-- Main Activity-->
<activity android:name=".YourActivityName" >
<intent-filter>
<!-- MAIN represents that it is the Main Activity-->
<action android:name="android.intent.action.MAIN" />
<!-- Launcher Denotes that it will be the first launching activity-->
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!--Add Other activities like this-->
<activity android:name=".YourActivityName2" >
<!--Default Intent Filter-->
<intent-filter>
<action android:name="android.intent.action.DEFAULT" />
</intent-filter>
</activity>
<!--OR Other activities like this And intent filter is not necessary in other activites-->
<activity android:name=".YourActivityName3" >
</activity>
<!--OR Add Other activities like this-->
<activity android:name=".YourActivityName4" />
这篇关于如何以正确的方式将Activity添加到manifest.xml?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文